WIP: feat(metric alerts): Add tests for differences in workflow-engine-rule-serializers output#109242
WIP: feat(metric alerts): Add tests for differences in workflow-engine-rule-serializers output#109242
Conversation
src/sentry/incidents/endpoints/serializers/workflow_engine_detector.py
Outdated
Show resolved
Hide resolved
src/sentry/incidents/endpoints/serializers/workflow_engine_detector.py
Outdated
Show resolved
Hide resolved
7545f67 to
35eade6
Compare
| data_source_detector = data_source_detectors.get(Q(detector=detector)) | ||
| query_subscription = query_subscriptions.get( | ||
| Q(id=data_source_detector.data_source.source_id) | ||
| ) |
There was a problem hiding this comment.
DataSourceDetector.DoesNotExist not handled in serializer loop
The .get(Q(detector=detector)) call at line 344 will raise DataSourceDetector.DoesNotExist if a detector exists without a corresponding DataSourceDetector record. This can happen during asynchronous deletion, incomplete migration, or edge cases in detector creation. When this crashes, the entire alert rule list endpoint returns a 500 instead of gracefully handling the missing record.
Verification
Read the full serializer at workflow_engine_detector.py lines 334-364. Confirmed DataSourceDetector.get() is called without DoesNotExist handling. Checked DataSourceDetector model (data_source_detector.py) - it's a lookup table with ForeignKey to Detector but no cascade delete. Confirmed the serializer is used in organization_alert_rule_index.py where detectors are fetched independently from DataSourceDetector records.
Identified by Warden sentry-backend-bugs · XXT-YE6
Backend Test FailuresFailures on
|
35eade6 to
a59b5e4
Compare
This aims to add tests to endpoints that use WorkflowEngineDetectorSerializer to compare to legacy behavior, reporting the diff.
It also includes some attempts to resolve these differences.