fix: Escape package names in UsersService methods - #4546
Open
pucedoteth wants to merge 1 commit into
Open
Conversation
GetPackage escaped packageName but the other seven UsersService package methods interpolated it raw, so a name containing a slash produced a malformed path. Container and scoped npm package names routinely contain one. OrganizationsService already escapes it in all seven equivalent methods, so this brings the user methods in line and adds the same doc note.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4546 +/- ##
=======================================
Coverage 98.54% 98.54%
=======================================
Files 196 196
Lines 17938 17938
=======================================
Hits 17677 17677
Misses 261 261 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
gmlewis
approved these changes
Sep 11, 2026
gmlewis
left a comment
Collaborator
There was a problem hiding this comment.
Thank you, @pucedoteth!
LGTM.
Awaiting second LGTM+Approval from any other contributor to this repo before merging.
| // GetPackage gets a package by name for a user. Passing the empty string for "user" will | ||
| // get the package for the authenticated user. | ||
| // | ||
| // Note that packageName is escaped for the URL path so that you don't need to. |
Contributor
There was a problem hiding this comment.
Suggested change
| // Note that packageName is escaped for the URL path so that you don't need to. | |
| // Note: the packageName is URL path escaped for you. See: https://pkg.go.dev/net/url#PathEscap . |
For consistency with rest of the repo.
go-github/github/repos_rules.go
Lines 15 to 22 in 2433615
Same applies to other occurrences in this PR.
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.
UsersService.GetPackageescapespackageName, but the other seven package methods interpolate it raw, so a name containing a slash produces a malformed path. Container and scoped npm package names routinely contain one.OrganizationsServicealready escapes it in all seven equivalent methods and documents it, so this just brings the user methods in line: 12 call sites escaped, plus the same doc note.The existing tests missed this because only the
GetPackagetest uses a slashed name (hello/hello_docker); the rest usehello_docker. The new test uses a slashed name against every affected method — all ten sub-cases fail without the change and pass with it.AI assistance: Claude Code found the inconsistency, made the edits, and drafted the test and this description. I reviewed the diff and ran
script/fmt.sh,script/generate.sh(no drift),script/lint.shandscript/test.sh.