Skip to content

fix(context): Redirect the user to the right page when a project was renamed#106643

Merged
shashjar merged 2 commits intomasterfrom
id-1231-fix-ownership-rules-page-infinite-loading-state-for-renamed-project
Jan 27, 2026
Merged

fix(context): Redirect the user to the right page when a project was renamed#106643
shashjar merged 2 commits intomasterfrom
id-1231-fix-ownership-rules-page-infinite-loading-state-for-renamed-project

Conversation

@shashjar
Copy link
Member

@shashjar shashjar commented Jan 21, 2026

Fixes ID-1231.

Slack thread for context

We were seeing a bug where the ownership rules page could show an infinite loading spinner when the old slug for a project that was renamed is provided. The API actually follows the redirect and gives us the up-to-date project slug, but we weren't following it. This PR updates the ProjectContextProvider component to redirect the user to the right page path in this case.

Here's a screen recording of the redirect experience.

Image of the redirect modal:
image

@linear
Copy link

linear bot commented Jan 21, 2026

@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Jan 21, 2026
}
)}
</Text>
<Flex direction="column" gap="lg">
Copy link
Member Author

Choose a reason for hiding this comment

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

Just aesthetic changes here, no changes to content. See screen recording for what it looks like.

if (project?.slug && project.slug !== projectSlug) {
redirectToProject(project.slug);
return;
}
Copy link
Member Author

Choose a reason for hiding this comment

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

As an alternative to actually initiating this redirect, I'm also fine with just showing the project as not found. Let me know if anyone has opinions about which experience is better / which one we should provide.

I guess the redirect is good for backwards compatibility with old links, but I don't think it's a huge benefit.

@shashjar shashjar requested review from a team and cvxluo January 21, 2026 00:38
@shashjar shashjar marked this pull request as ready for review January 21, 2026 00:39
Comment on lines +230 to +236
// Project exists but wasn't in store - this shouldn't normally happen
// but handle gracefully by showing not found error
this.setState({
loading: false,
error: true,
errorType: ErrorTypes.PROJECT_NOT_FOUND,
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Bug: The code incorrectly shows a "Project Not Found" error after successfully fetching a valid project from the API that was not in the local store.
Severity: HIGH

Suggested Fix

After a successful API fetch where the project slug matches, instead of setting an error state, update the component state with the fetched project data. This would likely involve calling this.setState with the new project information and setting loading to false, ensuring the project is rendered correctly.

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/views/projects/projectContext.tsx#L230-L236

Potential issue: When a project is not found in the local store, an API request is made
to fetch it. If this request is successful and the returned project's slug matches the
requested slug, the code incorrectly proceeds to set an error state with `error: true`
and `errorType: ErrorTypes.PROJECT_NOT_FOUND`. This means that when a user navigates to
a valid project that isn't yet loaded in the `ProjectsStore`, they will be shown a
"Project Not Found" error instead of the project's content. The correct behavior would
be to update the state with the successfully fetched project data.

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

Copy link
Member Author

Choose a reason for hiding this comment

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

this edge case was previously another infinite loading scenario, i think at least we should handle this more gracefully but not sure if we want to actually populate the store - open to opinions here

Copy link
Contributor

@cvxluo cvxluo left a comment

Choose a reason for hiding this comment

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

lgtm 👍

@shashjar shashjar merged commit 8745457 into master Jan 27, 2026
55 checks passed
@shashjar shashjar deleted the id-1231-fix-ownership-rules-page-infinite-loading-state-for-renamed-project branch January 27, 2026 18:18
priscilawebdev pushed a commit that referenced this pull request Feb 2, 2026
…renamed (#106643)

Fixes
[ID-1231](https://linear.app/getsentry/issue/ID-1231/project-ownership-settings-infinite-loading).

[Slack thread for
context](https://sentry.slack.com/archives/CQDHVRS2W/p1768517227023729)

We were seeing a bug where the ownership rules page could show an
infinite loading spinner when the old slug for a project that was
renamed is provided. The API actually follows the redirect and gives us
the up-to-date project slug, but we weren't following it. This PR
updates the `ProjectContextProvider` component to redirect the user to
the right page path in this case.


[Here's](https://drive.google.com/file/d/1cWEAGBMb3_h5oEVyKZ7XE31ZZHvgEUjY/view?usp=sharing)
a screen recording of the redirect experience.

Image of the redirect modal:
<img width="719" height="267" alt="image"
src="https://github.com/user-attachments/assets/0385ca2b-e718-4c24-85a5-4de62495c8ed"
/>
@github-actions github-actions bot locked and limited conversation to collaborators Feb 12, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants