Webhooks sent despite protection rule block #9219

Closed
opened 2025-12-29 20:47:11 +01:00 by adam · 2 comments
Owner

Originally created by @ryankearney on GitHub (Feb 8, 2024).

Originally assigned to: @jeremystretch on GitHub.

Deployment Type

Self-hosted

NetBox Version

v3.7.2

Python Version

3.10

Steps to Reproduce

  1. Create a webhook that triggers on an IP Address delete
  2. Create a custom protection rule that will block deletion if IP addresses. For example: { "ipam.ipaddress": [ { "status": { "eq": "deprecated" } } ] }
  3. Go delete an IP address object that does not satisfy the protection rule
  4. Observe the error message Deletion is prevented by a protection rule: {'status': ['Ensure this value is equal to deprecated.']} (this is expected)
  5. Observe the webhook firing for an ipaddress deletion (this is unexpected)

Expected Behavior

Webhook should not fire on deletion if a protection rule prevented the deletion from happening.

Observed Behavior

Webhook is sent sent with event deleted and a snapshot.postchange value of null despite the system blocking this deletion. This could have implications on webhook receivers processing the deletion when in fact the object remains in NetBox.

Originally created by @ryankearney on GitHub (Feb 8, 2024). Originally assigned to: @jeremystretch on GitHub. ### Deployment Type Self-hosted ### NetBox Version v3.7.2 ### Python Version 3.10 ### Steps to Reproduce 1. Create a webhook that triggers on an IP Address delete 2. Create a custom protection rule that will block deletion if IP addresses. For example: ```{ "ipam.ipaddress": [ { "status": { "eq": "deprecated" } } ] }``` 3. Go delete an IP address object that does not satisfy the protection rule 4. Observe the error message ` Deletion is prevented by a protection rule: {'status': ['Ensure this value is equal to deprecated.']}` (this is expected) 5. Observe the webhook firing for an ipaddress deletion (this is unexpected) ### Expected Behavior Webhook should not fire on deletion if a protection rule prevented the deletion from happening. ### Observed Behavior Webhook is sent sent with event `deleted` and a `snapshot.postchange` value of `null` despite the system blocking this deletion. This could have implications on webhook receivers processing the deletion when in fact the object remains in NetBox.
adam added the type: bugstatus: acceptedseverity: mediumtopic: event rules labels 2025-12-29 20:47:11 +01:00
adam closed this issue 2025-12-29 20:47:11 +01:00
Author
Owner

@renatoalmeidaoliveira commented on GitHub (Feb 12, 2024):

I can think in two ways to solve this Issue
1 Change handle_deleted_object event to post_delete.
2 Join handle_deleted_object and run_delete_validators in a single pre_delete method.
If I would fix that issue I would go for option 2.
I can make a fix for that issue, just let me know which path is the best.

@renatoalmeidaoliveira commented on GitHub (Feb 12, 2024): I can think in two ways to solve this Issue 1 Change handle_deleted_object event to post_delete. 2 Join handle_deleted_object and run_delete_validators in a single pre_delete method. If I would fix that issue I would go for option 2. I can make a fix for that issue, just let me know which path is the best.
Author
Owner

@jeremystretch commented on GitHub (Feb 13, 2024):

  1. Change handle_deleted_object event to post_delete.

I don't think this is feasible, because the receiver function is also responsible for recording a change record. This must happen before the object is deleted e.g. to retain its primary key.

  1. Join handle_deleted_object and run_delete_validators in a single pre_delete method.

IMO this would be the preferred solution.

@jeremystretch commented on GitHub (Feb 13, 2024): > 1. Change `handle_deleted_object` event to `post_delete`. I don't think this is feasible, because the receiver function is also responsible for recording a change record. This must happen _before_ the object is deleted e.g. to retain its primary key. > 2. Join `handle_deleted_object` and `run_delete_validators` in a single pre_delete method. IMO this would be the preferred solution.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#9219