Skip to content

fix: URL-encode branch names in GitHub API calls#1326

Open
anishesg wants to merge 1 commit into
anthropics:mainfrom
proudhare:fix/ph-issue-1314
Open

fix: URL-encode branch names in GitHub API calls#1326
anishesg wants to merge 1 commit into
anthropics:mainfrom
proudhare:fix/ph-issue-1314

Conversation

@anishesg
Copy link
Copy Markdown

Branch names containing special characters like # were failing when used in GitHub API calls because these characters have special meaning in URLs. The API would interpret # as a fragment separator, truncating the branch name and causing 404 errors. This fix introduces encodeBranchNameForAPI that wraps encodeURIComponent to properly percent-encode branch names before they are used in API paths. The function is applied in branch.ts, branch-cleanup.ts, update-comment-link.ts, and github-file-ops-server.ts wherever branch names are inserted into API URLs. Operations like getting branch refs, comparing commits, deleting branches, and updating refs now handle special characters correctly.

Fixes #1314

Branch names containing special characters like # were failing when used in GitHub API calls because these characters have special meaning in URLs. The API would interpret # as a fragment separator, truncating the branch name and causing 404 errors. This fix introduces `encodeBranchNameForAPI` that wraps `encodeURIComponent` to properly percent-encode branch names before they are used in API paths. The function is applied in `branch.ts`, `branch-cleanup.ts`, `update-comment-link.ts`, and `github-file-ops-server.ts` wherever branch names are inserted into API URLs. Operations like getting branch refs, comparing commits, deleting branches, and updating refs now handle special characters correctly.

Signed-off-by: anish <anishesg@users.noreply.github.com>
@anishesg anishesg marked this pull request as ready for review May 20, 2026 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

workflow validation failed if base branch's name has # in it

1 participant