-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
fix(preprod): Remove organization slug from legacy URL redirects #106970
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,11 @@ | ||
| import {useEffect} from 'react'; | ||
|
|
||
| import ConfigStore from 'sentry/stores/configStore'; | ||
| import {useLocation} from 'sentry/utils/useLocation'; | ||
| import {useNavigate} from 'sentry/utils/useNavigate'; | ||
| import useOrganization from 'sentry/utils/useOrganization'; | ||
| import {useParams} from 'sentry/utils/useParams'; | ||
| import useProjectFromSlug from 'sentry/utils/useProjectFromSlug'; | ||
|
|
||
| export default function LegacyPreprodRedirect() { | ||
| const params = useParams<{ | ||
|
|
@@ -15,31 +17,40 @@ export default function LegacyPreprodRedirect() { | |
| const navigate = useNavigate(); | ||
| const organization = useOrganization(); | ||
| const location = useLocation(); | ||
| const project = useProjectFromSlug({organization, projectSlug: params.projectId}); | ||
|
|
||
| useEffect(() => { | ||
| const {projectId, artifactId, headArtifactId, baseArtifactId} = params; | ||
| if (!project) { | ||
| return; | ||
| } | ||
|
|
||
| const {artifactId, headArtifactId, baseArtifactId} = params; | ||
| const numericProjectId = project.id; | ||
| const isInstall = location.pathname.includes('/install/'); | ||
| const isCompare = location.pathname.includes('/compare/'); | ||
|
|
||
| const {customerDomain} = ConfigStore.getState(); | ||
| const orgPrefix = customerDomain ? '' : `/organizations/${organization.slug}`; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok this should work but I'm not sure how to test this customerDomain logic locally.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Which side of the logic are you not able to test? |
||
|
|
||
| let newPath = ''; | ||
|
|
||
| if (isCompare && headArtifactId) { | ||
| const compareType = 'size'; | ||
| if (baseArtifactId) { | ||
| newPath = `/organizations/${organization.slug}/preprod/${compareType}/compare/${headArtifactId}/${baseArtifactId}/?project=${projectId}`; | ||
| newPath = `${orgPrefix}/preprod/${compareType}/compare/${headArtifactId}/${baseArtifactId}/?project=${numericProjectId}`; | ||
| } else { | ||
| newPath = `/organizations/${organization.slug}/preprod/${compareType}/compare/${headArtifactId}/?project=${projectId}`; | ||
| newPath = `${orgPrefix}/preprod/${compareType}/compare/${headArtifactId}/?project=${numericProjectId}`; | ||
| } | ||
| } else if (isInstall && artifactId) { | ||
| newPath = `/organizations/${organization.slug}/preprod/install/${artifactId}/?project=${projectId}`; | ||
| newPath = `${orgPrefix}/preprod/install/${artifactId}/?project=${numericProjectId}`; | ||
| } else if (artifactId) { | ||
| newPath = `/organizations/${organization.slug}/preprod/size/${artifactId}/?project=${projectId}`; | ||
| newPath = `${orgPrefix}/preprod/size/${artifactId}/?project=${numericProjectId}`; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Query parameter changed from slug to numeric IDMedium Severity The
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (I updated) |
||
| } | ||
|
|
||
| if (newPath) { | ||
| navigate(newPath, {replace: true}); | ||
| } | ||
| }, [params, navigate, organization, location]); | ||
| }, [params, navigate, organization, location, project]); | ||
|
|
||
| return null; | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Invalid project slugs cause blank page forever
Medium Severity
The early return when
!projectblocks redirects for invalid or inaccessible project slugs. Previously, the redirect always executed, letting the destination page handle errors. Now, ifuseProjectFromSlugreturnsundefinedpermanently (invalid slug, deleted project, or no access), no redirect occurs and the component rendersnull, leaving users stuck on a blank page with no feedback.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is fine. We're going to kill this redirect shortly anyway.