Repository navigation
Can't delete or query packages with forward slash in their names #9798
Copy link
Copy link
Open
Labels
discussFeature changes that require discussion primarily among the GitHub CLI teamFeature changes that require discussion primarily among the GitHub CLI teamenhancementa request to improve CLIa request to improve CLIgh-apirelating to the gh api commandrelating to the gh api command
Description
Describe the bug
Can't delete or query packages with forward slash in their names
Steps to reproduce the behavior
List packages:
gh api /users/skarlso/packages\?package_type=container --jq '.[].name'
...
ocm/v0.0.1/component-descriptors/github.com/skarlso/ocm-test
ocm/v0.0.2/component-descriptors/github.com/skarlso/ocm-workflow-class
ocm-workflow-class/v0.0.1
ocm/v0.0.1/component-descriptors/github.com/skarlso/ocm-workflow-class
ocm-destination/v0.0.1/component-descriptors/github.com/skarlso/ocm-workflow-class
ocm/component-descriptors/github.com/skarlso/ocm-workflow-class
ocm-destination/component-descriptors/github.com/skarlso/ocm-workflow-class
ocm-replication-test/component-descriptors/github.com/skarlso/ocm-replication-test
ocm-replication-test-example/v0.0.1
ocm-replication/component-descriptors/github.com/skarlso/ocm-replication
ocm-destination/skarlso/ocm-replication-test-example/v0.0.1
ocm-destination/component-descriptors/github.com/skarlso/ocm-replication
ocm-delivery/weaveworksdemos/carts
ocm-delivery/gardener-project/test/jensh007/mongo
ocm-delivery/component-descriptors/github.com/weaveworks/carts
ocm-delivery/weaveworksdemos/catalogue
ocm-delivery/weaveworksdemos/catalogue-db
ocm-delivery/component-descriptors/github.com/weaveworks/catalogue
ocm-delivery/weaveworksdemos/front-end
ocm-delivery/component-descriptors/github.com/weaveworks/front-end
ocm-delivery/weaveworksdemos/orders
ocm-delivery/component-descriptors/github.com/weaveworks/orders
ocm-delivery/weaveworksdemos/payment
ocm-delivery/component-descriptors/github.com/weaveworks/payment
ocm-delivery/weaveworksdemos/queue-master
ocm-delivery/library/rabbitmq
ocm-delivery/kbudde/rabbitmq-exporter
ocm-delivery/library/redis
ocm-delivery/component-descriptors/github.com/weaveworks/queue-master
ocm-delivery/weaveworksdemos/shipping
Query:
gh api -H "Accept: application/vnd.github+json" /users/skarlso/packages/container/ocm-delivery/weaveworksdemos/shipping
...
gh: Not Found (HTTP 404)
{
"message": "Not Found",
"documentation_url": "https://docs.github.com/rest",
"status": "404"
}
## Or
gh api \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/user/packages/container/ocm-delivery/weaveworksdemos/shipping
gh: Not Found (HTTP 404)
{
"message": "Not Found",
"documentation_url": "https://docs.github.com/rest",
"status": "404"
}
Expected vs actual behavior
A clear and concise description of what you expected to happen and what actually happened.
Logs
Paste the activity from your command line. Redact if needed.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
discussFeature changes that require discussion primarily among the GitHub CLI teamFeature changes that require discussion primarily among the GitHub CLI teamenhancementa request to improve CLIa request to improve CLIgh-apirelating to the gh api commandrelating to the gh api command
Activity
Skarlso commentedon Oct 21, 2024
For the record, deleting and retrieving a package that doesn't have a slash in its name, does work:
{ "id": 5684160, "name": "cert-manager-webhook", "package_type": "container", "owner": { "login": "Skarlso", "id": 182850, "node_id": "MDQ6VXNlcjE4Mjg1MA==", "avatar_url": "https://avatars.githubusercontent.com/u/182850?v=4", "gravatar_id": "", "url": "https://api.github.com/users/Skarlso", "html_url": "https://github.com/Skarlso", "followers_url": "https://api.github.com/users/Skarlso/followers", "following_url": "https://api.github.com/users/Skarlso/following{/other_user}", "gists_url": "https://api.github.com/users/Skarlso/gists{/gist_id}", "starred_url": "https://api.github.com/users/Skarlso/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/Skarlso/subscriptions", "organizations_url": "https://api.github.com/users/Skarlso/orgs", "repos_url": "https://api.github.com/users/Skarlso/repos", "events_url": "https://api.github.com/users/Skarlso/events{/privacy}", "received_events_url": "https://api.github.com/users/Skarlso/received_events", "type": "User", "user_view_type": "public", "site_admin": false }, "version_count": 6, "visibility": "public", "url": "https://api.github.com/users/Skarlso/packages/container/cert-manager-webhook", "created_at": "2023-10-03T15:10:54Z", "updated_at": "2023-10-03T15:28:33Z", "html_url": "https://github.com/users/Skarlso/packages/container/package/cert-manager-webhook" }Skarlso commentedon Oct 22, 2024
The name has to be URL encoded with
%2F.williammartin commentedon Oct 23, 2024
@Skarlso,
Looking at this it sort of seems like we should be URL encoding this on the client? What you've discovered seems like a pretty terrible experience. I suspect it hasn't come up before just because for the most part names don't have these characters.
What do you think about reopening this to get a better experience here?
Skarlso commentedon Oct 23, 2024
Yeah sure. Let's do that. It would be super nice indeed. 😊
williammartin commentedon Oct 23, 2024
Acceptance Criteria
When I target a resource using
gh apithat has characters that have special meaning and should be percent-encodedThen the request is made successfully
Skarlso commentedon Feb 27, 2025
Thank you for doing this! :) <3
williammartin commentedon Mar 18, 2025
Sorry @Skarlso, I've reverted the PR that fixed this because it caused some other issues. I'm reopening it so another attempt can be made, but it's likely there will be a release today that breaks you again: #10630
Skarlso commentedon Mar 18, 2025
No worries. :D Thank you for letting me know. :)
andyfeller commentedon Mar 18, 2025
@Skarlso : Nice to meet you! I'd like to ask you a few questions to figure out how we can help you in light of all of this. 🙇
Questions
ghfor working with these endpoints?Thoughts
This need completely makes sense as most programming languages provide libraries to help developers address this issue natively, however there are few standalone Linux/Windows/Mac utilities for shell and scripting use:
curl --data-urlencode <data>jq @uriformatHowever, I genuinely believe this problem needs a different approach:
ghshould be in this situationSeeing several homegrown tools on GitHub that people have put together to call Go
url.PathEscape(), perhaps we have a standaloneclitool that does something similar if not a standaloneghcommand. 🤔Skarlso commentedon Mar 18, 2025
@andyfeller Thank you very much! It's really not that big of a problem :) I just adjusted my own pathing and that's it. :)
AdamuKaapan commentedon Apr 24, 2026
Something else to contribute here - the
%2Ffix works for getting/deleting specific packages. However, packages with slashes in the name also are not appearing in list responses, and this has no way to fix locally. e.g. if we dogh api orgs/<org name>/packages?package_type=container, packages with a slash in the name are not returned.