Skip to content

fix(tests): Fix flaky test_get_or_create_user non-deterministic ordering#108919

Draft
joshuarli wants to merge 2 commits intomasterfrom
fix/flaky-test-get-or-create-user-ordering
Draft

fix(tests): Fix flaky test_get_or_create_user non-deterministic ordering#108919
joshuarli wants to merge 2 commits intomasterfrom
fix/flaky-test-get-or-create-user-ordering

Conversation

@joshuarli
Copy link
Member

@joshuarli joshuarli commented Feb 22, 2026

Summary

  • Add explicit order_by('id') to the user query in get_user_by_email so that when multiple users share the same email, the user with the lowest ID is consistently returned
  • Without explicit ordering, the DB may return users in any order, making the "first user" non-deterministic
  • The code comment already says "return the first user if ident is None" but the queryset lacked ordering to make "first" deterministic

Fixes #108910
Fixes #108925

Add explicit `order_by('id')` to the user query in `get_user_by_email`
so that when multiple users share the same email, the user with the
lowest ID is consistently returned. Without explicit ordering, the DB
may return users in any order making the "first user" non-deterministic.

Fixes #108910
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Feb 22, 2026
@joshuarli
Copy link
Member Author

ehh maybe we should not change this and instead adapt the tests

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

Labels

flaky-test Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

1 participant