Skip to content

fix: handle projects with multi-level namespaces#3092

Open
xingzihai wants to merge 1 commit intopackit:mainfrom
xingzihai:fix-multi-level-namespaces
Open

fix: handle projects with multi-level namespaces#3092
xingzihai wants to merge 1 commit intopackit:mainfrom
xingzihai:fix-multi-level-namespaces

Conversation

@xingzihai
Copy link
Copy Markdown

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 like organization/team or org/suborg/project.

Solution

Changed the route pattern from <namespace> to <path:namespace> which allows matching namespaces with slashes (multi-level namespaces).

Changes

  • Updated API routes in projects.py to use <path:namespace>
  • Updated API routes in usage.py to use <path:namespace>

Testing

  • Tested with single-level namespaces (existing behavior preserved)
  • Tested with multi-level namespaces (now works correctly)

Example

Before: /github/org/team/repo would fail to match
After: /github/org/team/repo correctly matches with namespace=org/team

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
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@centosinfra-prod-github-app
Copy link
Copy Markdown
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

2 participants