fix: handle projects with multi-level namespaces#3092
Conversation
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.
|
Build succeeded. ✔️ pre-commit SUCCESS in 1m 48s |
9d6dc44 to
32da30f
Compare
|
Build succeeded. ✔️ pre-commit SUCCESS in 1m 52s |
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
32da30f to
29aa1c5
Compare
|
Build succeeded. ✔️ pre-commit SUCCESS in 1m 56s |
|
Build succeeded (gate pipeline). ✔️ pre-commit SUCCESS in 1m 55s |
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