Add SourcemapDetectorHandler with atomic state transitions#109633
Add SourcemapDetectorHandler with atomic state transitions#109633wedamija wants to merge 1 commit intodanf/refactor-eventerror-strenumfrom
Conversation
Implements the detector handler for sourcemap configuration issues. Extends StatefulDetectorHandler but overrides evaluate_impl to skip dedupe/threshold logic and use atomic filter().update() on DetectorState as a lock to prevent duplicate occurrence creation across concurrent processes. Resolution is handled separately by a periodic task.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
| return 1 | ||
| except IntegrityError: | ||
| # Another process created the row first, just exit | ||
| return 0 |
There was a problem hiding this comment.
Missing transaction.atomic() around create() catching IntegrityError
Medium Severity
The IntegrityError from DetectorState.objects.create() is caught without wrapping the call in transaction.atomic(). In PostgreSQL, a failed statement inside a transaction aborts the entire transaction. While this works in autocommit mode (current production path), if _try_state_transition is ever called inside a transaction.atomic() block — including Django's TestCase which wraps every test in one — the caught IntegrityError leaves the connection in a broken state, causing subsequent DB operations to fail with TransactionManagementError. The codebase already follows the correct pattern in processors/action.py, where IntegrityError is caught from a transaction.atomic() block.


Implements the detector handler for sourcemap configuration issues. Extends StatefulDetectorHandler but overrides evaluate_impl to skip dedupe/threshold logic and use atomic filter().update() on DetectorState as a lock to prevent duplicate occurrence creation across concurrent processes. Resolution is handled separately by a periodic task.