Repository navigation
fix(java,csharp): escape personal access token name in HTTP delete path - #4897
Mitshah2406 wants to merge 2 commits into
Conversation
|
Thanks for the PR. It is labeled If AI assistance was used to create this PR, you are required to run the Slash commands (own line, regular comment) move it around the queue:
See CONTRIBUTING.md for details. |
|
/skill team-review |
There was a problem hiding this comment.
Summary: The Java and C# clients now send the personal access token name as one percent-encoded path segment and reject null and dot-segment names, and the new tests assert the exact request paths. One documentation nit remains on the C# exception contract, and the C# malformed-Unicode parity was left out because the diff does not change that behavior and only a .NET runtime check could settle it.
Counts: critical 0, warning 0, nit 1, simplification 0
This review was generated by Claude Code 2.1.310 on deepseek-flash[1m]. Review the output before you act on it.
| /// <param name="token">The cancellation token to cancel the operation.</param> | ||
| /// <returns>A task representing the asynchronous operation.</returns> | ||
| /// <exception cref="ArgumentException"> | ||
| /// Over HTTP, thrown when <paramref name="name" /> is null, "." or "..". |
There was a problem hiding this comment.
nit: The doc scopes the null case to HTTP, but TcpMessageStream.DeletePersonalAccessTokenAsync(null) also throws ArgumentException through WireName.ByteCount. Say that null throws on both transports and that "." and ".." throw only over HTTP.
Which issue does this PR address?
Closes #4672
Rationale
The Java and C# SDKs delete a personal access token (a named API key) with
DELETE /personal-access-tokens/{name}, but built the URL by pasting the name in as is. Characters that mean something in a URL then changed the request:../users/42sentDELETE /users/42, anda?b=cdeleted the tokena. The Rust SDK already escapes the name (#4628).What changed?
Both SDKs now percent-encode the name so it is always one path segment (
a/bbecomesa%2Fb). The names.and..are rejected with an exception, because URL parsers treat them as path navigation even when encoded. A null name now fails before any request is sent.In Java, a space is encoded as
%20and not the+thatURLEncoderproduces, because+in a path is a literal plus. Each SDK gets one test that records the exact path it sends.Local Execution
New tests (failing before, passing now), the C# unit suite, Java and C# lint,
prek run, and a delete ofa/b,my tokenand../users/42with both clients against a localiggy-server.AI Usage