Skip to content

fix(urls): Fix customer domain path regex rejecting org slugs starting with 'new'#109097

Draft
joshuarli wants to merge 2 commits intomasterfrom
fix/flaky-test-redirect-customer-domain
Draft

fix(urls): Fix customer domain path regex rejecting org slugs starting with 'new'#109097
joshuarli wants to merge 2 commits intomasterfrom
fix/flaky-test-redirect-customer-domain

Conversation

@joshuarli
Copy link
Member

Summary

  • Fix a bug in customer_domain_path() regex in src/sentry/organizations/absolute_url.py where the negative lookahead (?!new) was too broad
  • The intent was to exclude only the literal path /organizations/new/ (create new org page), but it accidentally excluded any org slug starting with "new" (e.g., "newt-corp", "newsletter")
  • Changed (?!new) to (?!new\/) so only the exact slug "new" followed by "/" is excluded
  • The test was flaky because create_organization() uses random names via petname.generate() — when a name starting with "new" was generated, absolute_url() failed to strip the /organizations/{slug}/ prefix from the path
  • Also pinned the test org to a deterministic name and added a regression test for org slugs starting with "new"

Test plan

  • Test passes 10/10 consecutive local runs
  • Added regression test case for /organizations/newt-corp/issues//issues/
  • Existing test case /organizations/new//organizations/new/ still passes

Fixes #109061

…g with "new"

The `customer_domain_path` regex used `(?\!new)` as a negative lookahead to
skip the `/organizations/new/` route (create new org), but this also blocked
any org slug starting with "new" (e.g. "newt-corp", "newsletter"). Changed
to `(?\!new/)` to only exclude the exact "new" slug.

This was the root cause of the flaky test `test_redirect_to_event_customer_domain`
which used a randomly generated org name via petname. When the random name
happened to start with "new", the redirect URL retained the `/organizations/slug/`
prefix instead of stripping it for customer domains.

Also pins the test org to a deterministic name to prevent other
similar issues from random name generation.
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Feb 23, 2026
@joshuarli
Copy link
Member Author

why the changes in tests/sentry/web/frontend/test_project_event.py?

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

Development

Successfully merging this pull request may close these issues.

Flaky test: tests/sentry/web/frontend/test_project_event.py::ProjectEventCustomerDomainTest::test_redirect_to_event_customer_domain

1 participant