Use a custom exception for object permission failures #4868

Closed
opened 2025-12-29 19:21:25 +01:00 by adam · 1 comment
Owner

Originally created by @jweiher on GitHub (May 4, 2021).

Originally assigned to: @jeremystretch on GitHub.

NetBox version

v2.11.2

Python version

3.9

Steps to Reproduce

  1. Create a plugin which hooks to a pre_save signal
  2. Have an uncatched ObjectDoesNotExist exception in this plugin
  3. See the Error "Object save failed due to object-level permissions violation"

Expected Behavior

It took us some time to debug this. It would be way nicer if either the object-level permission violation would get their own Exception instead of this re-interpretation of "ObjectDoesNotExist".

Observed Behavior

There is a re-interpretation of ObjectDoesNotExist to "Object save failed due to object-level permissions violation". This happens here: https://github.com/netbox-community/netbox/blob/develop/netbox/netbox/views/generic.py#L321

Originally created by @jweiher on GitHub (May 4, 2021). Originally assigned to: @jeremystretch on GitHub. ### NetBox version v2.11.2 ### Python version 3.9 ### Steps to Reproduce 1. Create a plugin which hooks to a pre_save signal 2. Have an uncatched ObjectDoesNotExist exception in this plugin 3. See the Error "Object save failed due to object-level permissions violation" ### Expected Behavior It took us some time to debug this. It would be way nicer if either the object-level permission violation would get their own Exception instead of this re-interpretation of "ObjectDoesNotExist". ### Observed Behavior There is a re-interpretation of ObjectDoesNotExist to "Object save failed due to object-level permissions violation". This happens here: https://github.com/netbox-community/netbox/blob/develop/netbox/netbox/views/generic.py#L321
adam added the status: acceptedtype: housekeeping labels 2025-12-29 19:21:25 +01:00
adam closed this issue 2025-12-29 19:21:25 +01:00
Author
Owner

@jeremystretch commented on GitHub (May 5, 2021):

  1. Have an uncatched ObjectDoesNotExist exception in this plugin

While we can do some work in core to help mitigate this, it is the plugin author's responsibility to ensure any such exceptions are handled.

@jeremystretch commented on GitHub (May 5, 2021): > 2. Have an uncatched ObjectDoesNotExist exception in this plugin While we can do some work in core to help mitigate this, it is the plugin author's responsibility to ensure any such exceptions are handled.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#4868