fix: Escape package names in UsersService methods - #4546
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.57% +0.02%
==========================================
Files 196 197 +1
Lines 17938 18252 +314
==========================================
+ Hits 17677 17991 +314
Misses 261 261 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
gmlewis
left a comment
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. |
There was a problem hiding this comment.
| // 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.
|
Good catch, thanks — applied to all 8 occurrences in I'd matched Two small deviations from the literal suggestion, both to match the source you linked:
The result is byte-identical to the |
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.