Redirect renamed project slugs in API v2 project endpoint (fixes #4182)#4295
Open
eshu3104 wants to merge 2 commits into
Open
Redirect renamed project slugs in API v2 project endpoint (fixes #4182)#4295eshu3104 wants to merge 2 commits into
eshu3104 wants to merge 2 commits into
Conversation
functionzz
reviewed
Jul 7, 2026
Collaborator
There was a problem hiding this comment.
Looks good to me, if possible, can you extend the behavior to the /api/v2/locales/<locale_code> & /api/v2/<locale_code>/<project_slug> endpoints? The LocaleCodeHistory & ProjectSlugHistory models will be useful :).
You will need to edit the behavior of LocaleIndividualView & ProjectLocaleIndividualView in a similar manner as you have done here.
Co-authored-by: Jamie <164675620+functionzz@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
/api/v2/projects/<old-slug>/returned a 404 for renamed projects, while theweb UI redirects to the new slug. This adds a
retrieve()override toProjectIndividualViewwith the sameProjectSlugHistoryfallback: on afailed lookup, respond with a 302 to the current slug's URL. Unknown slugs
still return 404.
The fallback logic mirrors
get_project_or_redirect()inpontoon/base/services.py. The 404 path now runs one extra history query,hence the query-count update in
test_disabled_project.Tests:
test_project_renamed_slug_redirects(old slug returns a 302 with thecorrect
Location) andtest_project_unknown_slug_404s.Note: other slug-based endpoints and locale endpoints (via
LocaleCodeHistory)have the same gap. This PR only covers the endpoint from the issue; happy to
follow up on the rest.