fix: handle projects with multi-level namespaces#3092
Open
xingzihai wants to merge 1 commit intopackit:mainfrom
Open
fix: handle projects with multi-level namespaces#3092xingzihai wants to merge 1 commit intopackit:mainfrom
xingzihai wants to merge 1 commit intopackit:mainfrom
Conversation
Flask-RESTX routes were using <namespace> which doesn't match paths containing slashes (like multi-level GitLab namespaces). This fix converts all <namespace> route parameters to <path:namespace> using Flask's path converter, which correctly matches paths with slashes. Example: gitlab.com/cki-project/contrib/kwf-lib is now correctly parsed: - forge: gitlab.com - namespace: cki-project/contrib - repo_name: kwf-lib Files modified: - packit_service/service/api/projects.py (6 routes) - packit_service/service/api/usage.py (1 route) Fixes: packit#3063
Contributor
There was a problem hiding this comment.
Code Review
This pull request updates several API routes in projects.py and usage.py to use the path converter for the namespace parameter. This change enables support for multi-level namespaces that contain slashes, which is necessary for forges like GitLab. I have no feedback to provide.
Contributor
|
Build succeeded. ✔️ pre-commit SUCCESS in 1m 48s |
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.
Summary
This PR fixes an issue with handling projects that have multi-level namespaces.
Problem
The API routes were using
<namespace>which doesn't match multi-level namespaces likeorganization/teamororg/suborg/project.Solution
Changed the route pattern from
<namespace>to<path:namespace>which allows matching namespaces with slashes (multi-level namespaces).Changes
projects.pyto use<path:namespace>usage.pyto use<path:namespace>Testing
Example
Before:
/github/org/team/repowould fail to matchAfter:
/github/org/team/repocorrectly matches with namespace=org/team