fix: prevent double percent-encoding of URL path segments#306
Merged
Conversation
The URL() method assigned the encoded apiPath (containing %2F) directly to url.Path, which is Go's decoded field. When url.String() serialized the URL, it re-encoded the percent sign (%2F -> %252F), causing branch and revision names with slashes to be mangled in API requests. Set url.RawPath alongside url.Path so Go's URL serialization preserves the original percent-encoding.
The URL() method assigned the encoded apiPath (containing %2F) directly to url.Path, which is Go's decoded field. When url.String() serialized the URL, it re-encoded the percent sign (%2F -> %252F), causing branch and revision names with slashes to be mangled in API requests. Set url.RawPath alongside url.Path so Go's URL serialization preserves the original percent-encoding.
ThisIsDemetrio
approved these changes
May 13, 2026
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
Fixes a bug where branch/revision names containing slashes were double
percent-encoded in API request URLs. For example,
feat/external-idpwas encoded as
feat%252Fexternal-idpinstead offeat%2Fexternal-idp.Root Cause
Request.URL()ininternal/client/request.goassigned the encodedapiPath(fromEscapedPath(), containing%2F) directly tourl.Path, which in Go'snet/urlpackage is the decoded field.When
url.String()later serialized the URL, it calledEscapedPath()again, re-encoding the
%character itself (%→%25), producing%252F.Changes
Request.URL(), detect when the assembled path containspercent-encoded segments and properly split into decoded
url.Pathand encoded
url.RawPath.TestRequestURLverifying the final URL stringpreserves percent-encoded path segments.
TestDescribeProjectCmdto checkRawPathinstead of
Pathfor encoded segments, matching correct HTTPbehavior.
Testing
All existing tests pass. New test added covering the specific scenario.