[PR #19856] [CLOSED] Fix 19633 interrupting event processing in the process_event_rules() function #15736

Closed
opened 2025-12-30 00:23:44 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/19856
Author: @ravenrs
Created: 7/10/2025
Status: Closed

Base: mainHead: 19633-fix-in-condition-aval


📝 Commits (5)

  • 2f9e1ce Fixes #19633. Added new test cases to handle cases where the field being compared (x) doesn't exist in the data dictionary, which would result in None when trying to access it, and you want these comparisons to safely return False rather than raising an error.
  • 8c87975 Fixes #19633. Handle case that was the reason of TypeError and raise exeption: "TypeError: argument of type 'NoneType' is not iterable" with lead to breaking all events in the same object_type.
  • ee2aaa6 Fixes #19633 fix PEP8 compliance error of previous commit in test_conditions.py
  • ca9b294 Fixes #19633 typo error.
  • f41da06 Closes #19633

📊 Changes

5 files changed (+230 additions, -115 deletions)

View changed files

📝 netbox/extras/conditions.py (+8 -3)
📝 netbox/extras/events.py (+89 -85)
📝 netbox/extras/tests/test_conditions.py (+50 -26)
📝 netbox/extras/tests/test_event_rules.py (+64 -0)
📝 netbox/netbox/context_managers.py (+19 -1)

📄 Description

Fixes: #19633

  1. condition.py
  • Added condition to to check when value is None. It should return False or not False if self.negative is True.
  • Change condition with self.negate to result XOR self.negate for compactness.
  1. test_condition.py
  • Added test to cover cases when Value is None.
  1. context_manager.py
  • Added context manager suppress_event_exp to prevent missing exceptions in cycles related to sequential event handling
  1. event.py
  • Using cm suppress_event_exp.
  1. test_event_rules.py
  • Added test to emulate the exception in process_event_function and verify that exception was logged properly.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbox-community/netbox/pull/19856 **Author:** [@ravenrs](https://github.com/ravenrs) **Created:** 7/10/2025 **Status:** ❌ Closed **Base:** `main` ← **Head:** `19633-fix-in-condition-aval` --- ### 📝 Commits (5) - [`2f9e1ce`](https://github.com/netbox-community/netbox/commit/2f9e1cee048c70ab18f2fe72dd12d95bfc40dd26) Fixes #19633. Added new test cases to handle cases where the field being compared (x) doesn't exist in the data dictionary, which would result in None when trying to access it, and you want these comparisons to safely return False rather than raising an error. - [`8c87975`](https://github.com/netbox-community/netbox/commit/8c8797599baa1601af52c6f8b570026ea840fcc2) Fixes #19633. Handle case that was the reason of TypeError and raise exeption: "TypeError: argument of type 'NoneType' is not iterable" with lead to breaking all events in the same object_type. - [`ee2aaa6`](https://github.com/netbox-community/netbox/commit/ee2aaa6508da81f60cd147253900f203ac9c1b51) Fixes #19633 fix PEP8 compliance error of previous commit in test_conditions.py - [`ca9b294`](https://github.com/netbox-community/netbox/commit/ca9b2947ba6895cca4fdc09127fe7974eb4807b0) Fixes #19633 typo error. - [`f41da06`](https://github.com/netbox-community/netbox/commit/f41da06d9b4a9da1e4871e60bc318bfa7732936b) Closes #19633 ### 📊 Changes **5 files changed** (+230 additions, -115 deletions) <details> <summary>View changed files</summary> 📝 `netbox/extras/conditions.py` (+8 -3) 📝 `netbox/extras/events.py` (+89 -85) 📝 `netbox/extras/tests/test_conditions.py` (+50 -26) 📝 `netbox/extras/tests/test_event_rules.py` (+64 -0) 📝 `netbox/netbox/context_managers.py` (+19 -1) </details> ### 📄 Description <!-- Thank you for your interest in contributing to NetBox! Please note that our contribution policy requires that a feature request or bug report be approved and assigned prior to opening a pull request. This helps avoid waste time and effort on a proposed change that we might not be able to accept. IF YOUR PULL REQUEST DOES NOT REFERENCE AN ISSUE WHICH HAS BEEN ASSIGNED TO YOU, IT WILL BE CLOSED AUTOMATICALLY. Please specify your assigned issue number on the line below. --> ### Fixes: #19633 1. **condition.py** - Added condition to to check when value is None. It should return False or not False if self.negative is True. - Change condition with self.negate to result XOR self.negate for compactness. 2. **test_condition.py** - Added test to cover cases when Value is None. 3. **context_manager.py** - Added context manager suppress_event_exp to prevent missing exceptions in cycles related to sequential event handling 4. **event.py** - Using cm suppress_event_exp. 5. **test_event_rules.py** - Added test to emulate the exception in process_event_function and verify that exception was logged properly. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-30 00:23:44 +01:00
adam closed this issue 2025-12-30 00:23:44 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#15736