fix(tests): Fix flaky TestIncidentSerializer trigger ordering#108924
Closed
fix(tests): Fix flaky TestIncidentSerializer trigger ordering#108924
Conversation
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
ceorourke
approved these changes
Feb 24, 2026
Contributor
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.
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>
rbro112
approved these changes
Feb 25, 2026
Member
Author
|
Superseded by #109344 |
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
test_simpleandtest_detailedDataCondition.objects.filter()query inWorkflowEngineDetectorSerializerhas no explicitorder_by(), making the trigger list order non-deterministic_sort_triggershelper to normalize trigger order for comparisonFixes #108918