Skip to content

Add SourcemapDetectorHandler with atomic state transitions#109633

Open
wedamija wants to merge 1 commit intodanf/refactor-eventerror-strenumfrom
danf/sourcemap-config-issues/pr2-detector-handler
Open

Add SourcemapDetectorHandler with atomic state transitions#109633
wedamija wants to merge 1 commit intodanf/refactor-eventerror-strenumfrom
danf/sourcemap-config-issues/pr2-detector-handler

Conversation

@wedamija
Copy link
Member

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.

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.
@wedamija wedamija requested review from a team February 28, 2026 01:01
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Feb 28, 2026
Copy link
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant