Skip to content

fix(tests): Fix flaky TestIncidentSerializer trigger ordering#108924

Closed
joshuarli wants to merge 3 commits intomasterfrom
fix/flaky-test-incident-serializer-trigger-ordering
Closed

fix(tests): Fix flaky TestIncidentSerializer trigger ordering#108924
joshuarli wants to merge 3 commits intomasterfrom
fix/flaky-test-incident-serializer-trigger-ordering

Conversation

@joshuarli
Copy link
Copy Markdown
Member

Summary

  • Sort triggers by label before comparison in test_simple and test_detailed
  • The DataCondition.objects.filter() query in WorkflowEngineDetectorSerializer has no explicit order_by(), making the trigger list order non-deterministic
  • Added a _sort_triggers helper to normalize trigger order for comparison

Fixes #108918

Sort triggers by label before comparison since the
DataCondition.objects.filter() query in WorkflowEngineDetectorSerializer
has no explicit ordering, making the trigger list order non-deterministic.

Fixes #108918
@joshuarli joshuarli requested a review from rbro112 February 24, 2026 21:31
@joshuarli joshuarli marked this pull request as ready for review February 24, 2026 21:31
@joshuarli joshuarli requested a review from a team as a code owner February 24, 2026 21:31
Copy link
Copy Markdown
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.

Comment thread tests/sentry/incidents/serializers/test_workflow_engine_incident.py
Add `typing.Any` import and specify `dict[str, Any]` type parameters
on `_sort_triggers` to satisfy mypy's `type-arg` rule.

Co-Authored-By: Claude <noreply@anthropic.com>
@joshuarli
Copy link
Copy Markdown
Member Author

Superseded by #109344

@joshuarli joshuarli closed this Feb 25, 2026
joshuarli added a commit that referenced this pull request Feb 25, 2026
## Summary

Combined PR that supersedes 41 individual approved flaky test fix PRs.
All changes are test-only fixes addressing non-deterministic ordering,
ID collisions, timing races, and boundary conditions (one fix in
`src/sentry/models/group.py` for a wrong column alias).

## Supersedes

- #108628 fix(tests): fix flaky ordering in sampling project rates test
- #108629 fix(tests): fix flaky substring match in preprod status check
test
- #108630 fix(tests): fix flaky tool count in AI conversations tests
- #108642 fix(models): fix flaky test_without_snowflake sequence
assertion
- #108666 fix(tests): Fix flaky test_rate_limited by adding
indexer_cache fixture
- #108732 fix(tests): Fix flaky floored_epm tests by using exact time
window
- #108733 fix(tests): Fix flaky test_save_event_feedback group_id
mismatch
- #108821 fix(tests): Fix flaky test_issue_owners_should_ratelimit
group_id collision
- #108828 fix(tests): Fix flaky test_get_dsn settings leak from
test_absolute_url
- #108836 fix(issues): Fix EventOrdering using wrong column alias for
event_id
- #108840 fix(tests): Fix flaky test_login_ratelimited_ip_gets Redis TTL
issue
- #108846 fix(tests): Fix flaky test_sort_by_latest_group
non-deterministic ordering
- #108847 fix(tests): Fix flaky
test_schema_validator_rejects_none_fields cleanup
- #108850 fix(tests): Fix flaky
test_dart_multiple_exceptions_deobfuscation_direct cache collision
- #108868 fix(tests): Fix flaky test_batch_query_percent session timing
- #108875 fix(tests): Fix flaky test_get suspect flags group_id
collision
- #108892 fix(tests): Fix flaky detector serializer trigger ordering
- #108893 fix(tests): Fix flaky test_has_object_permission user ID
collision
- #108894 fix(tests): Fix flaky
test_relocate_recovery_post_multiple_orgs call ordering
- #108895 fix(tests): Fix flaky test_multiple_groups_same_project group
ordering
- #108898 fix(tests): Fix flaky UpdateAlertRuleTest project ordering
- #108899 fix(tests): Fix flaky test_duration timestamp precision
- #108904 fix(tests): Fix flaky test_user_delta_reached
non-deterministic group lookup
- #108906 fix(tests): Fix flaky test_taskworker_schedule_parameters
missing task imports
- #108916 fix(tests): Fix flaky test_get discover saved queries project
ordering
- #108917 fix(tests): Fix flaky test_update detector details condition
ordering
- #108921 fix(tests): Fix flaky
test_slow_condition_workflow_with_conditions timing
- #108924 fix(tests): Fix flaky TestIncidentSerializer trigger ordering
- #108945 fix(tests): Fix flaky
test_basic_post_with_invalid_integrationId ID collision
- #108946 fix(tests): Fix flaky test_link_all_repos non-deterministic
ordering
- #108949 fix(tests): Fix flaky test_disable_alerts_multiple_scopes
owner ordering
- #108957 fix(tests): Fix flaky test_get_projects_by_slugs_all project
ordering
- #108961 fix(tests): Fix flaky
test_update_with_project_write_bulk_enrollment snowflake ID collision
- #108975 fix(tests): Fix flaky test_query_single_group empty results
- #108978 fix(tests): Fix flaky test_unmerge hour boundary crossing
- #108991 fix(tests): Fix flaky test_gracefully_handles_missing_user ID
collision
- #108994 fix(tests): Fix flaky test_rate_limit Redis TTL expiry
- #109021 fix(tests): Fix flaky test_caching_many result ordering
- #109022 fix(tests): Fix flaky test_get explore saved queries project
ordering
- #109096 fix(tests): Fix flaky test_snuba_data timestamp precision
mismatch
- #109099 fix(monitors): Fix flaky test_rate_limit time bucket race
condition

## Categories of fixes

- **Non-deterministic ordering**: Sort results before assertion or use
deterministic ordering
- **ID collisions**: Use unique/explicit IDs to avoid snowflake
collisions
- **Timing/race conditions**: Freeze time or use deterministic
timestamps
- **State leaks**: Add proper test isolation and cleanup
- **Bug fix**: Fix wrong column alias in EventOrdering (#108836)

---------

Co-authored-by: Claude <noreply@anthropic.com>
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 13, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flaky test: tests/sentry/incidents/serializers/test_workflow_engine_incident.py::TestIncidentSerializer::test_detailed

3 participants