fix: prevent query params from being percent-encoded in API request path#207
Open
davhparry wants to merge 1 commit into
Open
fix: prevent query params from being percent-encoded in API request path#207davhparry wants to merge 1 commit into
davhparry wants to merge 1 commit into
Conversation
ApiService.request was passing the full URI (including query string) as the request path. url.URL then percent-encoded the '?' as '%3F' in the path while also appending the params via RawQuery, resulting in doubled and malformed query strings. Fix uses u.Path (path only) so params flow through RawQuery exclusively. Adds ApiService tests that verify params arrive correctly at the server and adds AddHandlerToMux to testlib for request inspection. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Description
ApiService.request was passing the full URI (including query string) as the request path. url.URL then percent-encoded the '?' as '%3F' in the path while also appending the params via RawQuery, resulting in doubled and malformed query strings. Fix uses u.Path (path only) so params flow through RawQuery exclusively.
Adds ApiService tests that verify params arrive correctly at the server and adds AddHandlerToMux to testlib for request inspection.
Fixes: 175
Type of Change
Changes Made
ApiService.requestwas passing the full URI string (e.g./automation-studio/projects?limit=10) directly as thepathfield of the client requesturl.URLtreated the?as a literal path character and percent-encoded it as%3F, while also appending the params viaRawQuery— resulting in a malformed, doubled URL like/automation-studio/projects%3Flimit=10?limit=10u.Path(path only) so query params flow exclusively throughRawQueryTesting
TestApiService_Get_WithQueryParamsInURI— regression test confirming params arrive at the server as a proper query string, not encoded in the pathTestApiService_Get_WithMultipleQueryParamsInURI— same for multiple paramsTestApiService_Delete_WithQueryParamsInURI— same fix applies to DELETEipctl api get '/automation-studio/projects' --params limit=10returns 200 against a live serverChecklist
make setupor relevant profiletype: subject)enhancement,bug,documentation,refactor,chore)