Repository navigation
fix(github): Percent-encode branch names and refs in URL paths - #175
Open
joseph-sentry wants to merge 1 commit into
Open
joseph-sentry wants to merge 1 commit into
joseph-sentry wants to merge 1 commit into
Conversation
`#` and `%` are legal in git ref names but end or corrupt a URL path, so calls naming a branch like `feature/#123-fix` hit `feature/` instead. Co-Authored-By: Claude Opus 5.5 <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.
The GitHub provider put branch names and refs into URL paths without encoding them.
#and%are legal in git ref names, so a branch likefeature/#123-fixwas created fine (the name goes in the request body), but every later call that names it in the path was cut off at the#and hitfeature/instead.In Seer that means reading the wrong branch's head, and a forced update could overwrite a different branch (raised on getsentry/seer#9354).
The provider now percent-encodes branch names, refs and SHAs before they go into a path, keeping
/literal as GitHub expects. That covers getting, updating and deleting a branch,get_git_ref, commits, compare, check runs and archive links. GitLab already encoded branch names.Not covered here: file paths in the contents endpoints have the same issue.
Verification
Ran through Sentry's scm-rpc proxy (a box's devserver) against a test repo with the branch
seer/test/#12-50%-encode-e2e:The box runs Sentry as one process, so the control-silo integration proxy hop isn't exercised. That hop sends the path from the already-encoded request URL in a header and rebuilds the URL with
urljoin, which keeps%23and%25as they are.🤖 Generated with Claude Code