Repository navigation
Can't delete or query packages with forward slash in their names #9798
Description
Activity
For the record, deleting and retrieving a package that doesn't have a slash in its name, does work:
gh api /user/packages/container/cert-manager-webhook{ "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" }The name has to be URL encoded with
%2F.Reacted by joundyLooking 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?
Reacted by Gergely BräutigamYeah sure. Let's do that. It would be super nice indeed. 😊
Reacted by William MartinAcceptance Criteria
When I target a resource using
gh apithat has characters that have special meaning and should be percent-encoded
Then the request is made successfully- addedenhancementa request to improve CLIa request to improve CLIgh-apirelating to the gh api commandrelating to the gh api commandhelp wantedContributions welcomeContributions welcomeand removedbugSomething isn't workingSomething isn't workingneeds-triageneeds to be reviewedneeds to be reviewed
on Oct 23, 2024 Thank you for doing this! :) <3
Reacted by AzeemReacted by Azeem- addeddiscussFeature changes that require discussion primarily among the GitHub CLI teamFeature changes that require discussion primarily among the GitHub CLI teamand removedhelp wantedContributions welcomeContributions welcome
on Mar 18, 2025 No worries. :D Thank you for letting me know. :)
@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
- What operating systems were you using
ghfor working with these endpoints? - What other alternatives to encoding URLs did you explore?
- Are there any concerns using a specialized tool for encoding and decoding?
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:
However, I genuinely believe this problem needs a different approach:
- this is a general HTTP request need, not just GitHub APIs
- I don't know where the Unix principle line gets drawn here in terms of responsibility
- I don't know how intelligent
ghshould be in this situation
Seeing 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. 🤔- What operating systems were you using
@andyfeller Thank you very much! It's really not that big of a problem :) I just adjusted my own pathing and that's it. :)
- osx
- yes, a simple bash script where I escape what I do "by hand"
if [[ $found -eq 1 ]]; then name=${1//\//%2F} echo "deleting package with name: $name" gh api -X DELETE "/user/packages/container/$name" --silent fi
- I'd like to limit the number of tools I use to a bare minimum
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.
Describe the bug
Can't delete or query packages with forward slash in their names
Steps to reproduce the behavior
List packages:
Query:
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.