Skip to content

Conversation

@runningcode
Copy link
Contributor

@runningcode runningcode commented Jan 23, 2026

Summary

Fixes legacy preprod URL redirects to use numeric project IDs instead of project slugs in the query parameter, with fallback to slug for backward compatibility.

Problem

When users access legacy preprod URLs in the format /preprod/{projectSlug}/{artifactId}/, the redirect was passing the project slug directly to the ?project= query parameter. However, the rest of the application expects numeric project IDs in this parameter for consistency and stability (project IDs don't change, slugs can).

Solution

  • Modified LegacyPreprodRedirect component to use useProjectFromSlug hook to fetch the full project object
  • Extracts the numeric ID from the project and uses it in the redirect
  • Falls back to using the slug if the project lookup fails (API error, project not found, etc.)
  • Applies to all redirect scenarios: size view, compare view, and install view

Behavior

When project is found:

/preprod/fishbox-ios/17532/ → /preprod/size/17532/?project=12345

When project is not found (fallback):

/preprod/unknown-project/17532/ → /preprod/size/17532/?project=unknown-project

This maintains backward compatibility and ensures users are never stuck on the legacy URL.

Testing

Added comprehensive test coverage in legacyUrlRedirect.spec.tsx covering:

  • Size view redirect with project ID
  • Compare view redirect with project ID
  • Install view redirect with project ID
  • Fallback to slug when project is not found

@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Jan 23, 2026
When legacy preprod URLs (format: /preprod/{slug}/{artifactId}/) are
accessed, the redirect now converts the project slug to its numeric
project ID before constructing the new URL format with query parameters.

This ensures consistency with the rest of the application which expects
numeric project IDs in the ?project= query parameter, not slugs.

Changes:
- Modified LegacyPreprodRedirect to use useProjectFromSlug hook
- Waits for project data to load before redirecting
- Converts slug to numeric ID for all redirect scenarios (size, compare, install)
- Added comprehensive tests for redirect behavior
The route parameter is named 'projectId' but actually contains a project
slug from the legacy URL format. Added explicit variable naming and
comments to make this clear:

- Renamed local variable to 'projectSlugFromUrl' to reflect actual content
- Added inline comment explaining the route param misnaming
- Updated comment to clarify we prefer numeric ID, fallback to slug

This makes the code's intent much clearer without changing behavior.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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