Skip to content

fix(tests): Fix flaky test_gracefully_handles_missing_user ID collision#108991

Closed
joshuarli wants to merge 1 commit intomasterfrom
fix/flaky-test-missing-user-id-collision
Closed

fix(tests): Fix flaky test_gracefully_handles_missing_user ID collision#108991
joshuarli wants to merge 1 commit intomasterfrom
fix/flaky-test-missing-user-id-collision

Conversation

@joshuarli
Copy link
Copy Markdown
Member

Summary

  • Use a large user ID (2147483647) instead of 999 to ensure the user doesn't exist in the test database
  • With sequential auto-increment IDs, user ID 999 can be created by other tests running before this one, causing the missing-user code path to be bypassed

Fixes #108980

Test plan

  • Ran test 10 times locally, all passed

Use a large user ID (2147483647) instead of 999 to ensure the user
doesn't exist in the test database. With sequential auto-increment IDs,
user ID 999 can be created by other tests running before this one,
causing the missing-user code path to be bypassed.

Fixes #108980
@joshuarli joshuarli requested a review from rbro112 February 24, 2026 00:44
@joshuarli joshuarli marked this pull request as ready for review February 24, 2026 00:44
@joshuarli joshuarli requested review from a team as code owners February 24, 2026 00:44
@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/sentry_apps/tasks/test_sentry_apps.py::TestInstallationWebhook::test_gracefully_handles_missing_user

2 participants