Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions static/app/router/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import {OverviewWrapper} from 'sentry/views/issueList/overviewWrapper';
import {IssueTaxonomy} from 'sentry/views/issueList/taxonomies';
import {OrganizationContainerRoute} from 'sentry/views/organizationContainer';
import {OrganizationLayout} from 'sentry/views/organizationLayout';
import {OrganizationStatsWrapper} from 'sentry/views/organizationStats/organizationStatsWrapper';
import {Tab as TransactionSummaryTab} from 'sentry/views/performance/transactionSummary/tabs';
import {ProjectEventRedirect} from 'sentry/views/projectEventRedirect';
import {redirectDeprecatedProjectRoute} from 'sentry/views/projects/redirectDeprecatedProjectRoute';
Expand Down Expand Up @@ -814,12 +813,21 @@ function buildRoutes(): RouteObject[] {
{
path: '/stats/',
withOrgPath: true,
Comment on lines 813 to 815
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Bug: When a route uses both withOrgPath: true and redirectTo, the withOrgPath property is ignored, preventing the creation of organization-prefixed redirect routes and causing 404 errors.
Severity: HIGH

Suggested Fix

Refactor the translateSentryRoute() function to ensure the withOrgPath logic is applied even when redirectTo is present. This likely involves processing withOrgPath to generate both base and organization-prefixed routes before handling the redirectTo property for each generated route.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: static/app/router/routes.tsx#L813-L815

Potential issue: In the `translateSentryRoute()` function, the logic returns early if a
`redirectTo` property is defined on a route. This early return occurs before the logic
that processes `withOrgPath: true` is reached. Consequently, for the new stats redirect
routes, only the non-organization paths (e.g., `/stats/`) are created, while the
organization-prefixed paths (e.g., `/organizations/:orgId/stats/`) are not. Users
navigating to these organization-specific stats paths will encounter a 404 error instead
of being correctly redirected.

Did we get this right? 👍 / 👎 to inform future reviews.

component: OrganizationStatsWrapper,
children: statsChildren,
redirectTo: '/settings/stats/',
},
{
path: '/stats/issues/',
withOrgPath: true,
redirectTo: '/settings/stats/issues/',
},
{
path: '/stats/health/',
withOrgPath: true,
redirectTo: '/settings/stats/health/',
},
{
path: '/organizations/:orgId/stats/team/',
redirectTo: '/organizations/:orgId/stats/issues/',
redirectTo: '/organizations/:orgId/settings/stats/issues/',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

withOrgPath silently ignored on redirectTo routes

High Severity

The withOrgPath: true on the three new redirect routes is silently ignored. In translateSentryRoute, when redirectTo is set, the function returns early on line 66–68 before reaching the withOrgPath dual-route logic. This means /organizations/:orgId/stats/, /organizations/:orgId/stats/issues/, and /organizations/:orgId/stats/health/ will no longer match any route and will 404 instead of redirecting to their /settings/stats/ equivalents. The old OrganizationStatsWrapper worked because it was a component, not a redirectTo, so withOrgPath was processed.

Fix in Cursor Fix in Web

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Team redirect targets nonexistent org-prefixed settings path

High Severity

The /organizations/:orgId/stats/team/ redirect now points to /organizations/:orgId/settings/stats/issues/, but no route exists at /organizations/:orgId/settings/.... The settings routes are defined at /settings/:orgId/... (since settingsRoutes uses path: '/settings/' without withOrgPath). Previously, this redirected to /organizations/:orgId/stats/issues/ which was then caught by the OrganizationStatsWrapper and correctly re-routed to /settings/:orgId/stats/issues/. The new target will hit the catch-all RouteNotFound instead.

Fix in Cursor Fix in Web

},
],
};
Expand Down
19 changes: 0 additions & 19 deletions static/app/views/organizationStats/organizationStatsWrapper.tsx

This file was deleted.

Loading