Skip to content

fix(tests): Clean up auth.allow-registration in system options tests#108296

Open
joshuarli wants to merge 2 commits intomasterfrom
fix/test-pollution-system-options-auth-allow-registration
Open

fix(tests): Clean up auth.allow-registration in system options tests#108296
joshuarli wants to merge 2 commits intomasterfrom
fix/test-pollution-system-options-auth-allow-registration

Conversation

@joshuarli
Copy link
Member

@joshuarli joshuarli commented Feb 14, 2026

found in this shuffle-tests-across-shards run https://github.com/getsentry/sentry/actions/runs/22010195505/job/63602406261

this consistently fails:

pytest tests/sentry/api/endpoints/test_system_options.py::SystemOptionsTest::test_put_self_hosted_superuser_access_allowed tests/sentry/web/frontend/test_oauth_authorize.py::OAuthAuthorizeCustomSchemeTest::test_code_flow_unauthenticated_custom_scheme

and was bisected here https://github.com/getsentry/sentry/actions/runs/22013373357/job/63611146322


  • Fix test pollution where SystemOptionsTest tests set auth.allow-registration to 1 via the API without cleaning up afterward
  • The leaked option caused has_user_registration() to return True in subsequent tests, breaking login redirect behavior (returning 200 instead of 302) in OAuthAuthorizeCustomSchemeTest::test_code_flow_unauthenticated_custom_scheme
  • Added options.delete("auth.allow-registration") cleanup in three tests: test_put_self_hosted_superuser_access_allowed, test_put_int_for_boolean, and test_update_channel

… tests

Three tests in SystemOptionsTest set `auth.allow-registration` to `1` via
the API without cleaning up, causing test pollution. This leaked option
made `has_user_registration()` return True in subsequent tests, breaking
login redirect behavior in OAuthAuthorizeCustomSchemeTest.
@joshuarli joshuarli force-pushed the fix/test-pollution-system-options-auth-allow-registration branch from 611da5f to cc43e32 Compare February 14, 2026 08:28
Copy link
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.

== options.UpdateChannel.APPLICATION
)
options.delete("auth.allow-registration")
assert response.status_code == 200
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cleanup skipped if preceding assertion fails in test

Medium Severity

In test_update_channel, options.delete("auth.allow-registration") is placed after the get_last_update_channel assertion (lines 117–120). If that assertion fails, the cleanup never executes and the test pollution this PR aims to fix still occurs. In contrast, the other two tests (test_put_self_hosted_superuser_access_allowed, test_put_int_for_boolean) correctly place options.delete immediately after the PUT, before any assertions. Additionally, moving assert response.status_code == 200 to the very end means a failed PUT would produce a confusing error from the get_last_update_channel check instead of a clear status code failure.

Fix in Cursor Fix in Web

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant