Skip to content

fix: allow Unicode branch names - #1022

Open
Lubrsy706 wants to merge 3 commits into
anthropics:mainfrom
Lubrsy706:fix/branch-name-validation-unicode-and-at
Open

Lubrsy706 wants to merge 3 commits into
anthropics:mainfrom
Lubrsy706:fix/branch-name-validation-unicode-and-at

Conversation

@Lubrsy706

@Lubrsy706 Lubrsy706 commented Mar 6, 2026 •

Copy link
Copy Markdown

Summary

Fixes #1020.

The ASCII-only whitelist in validateBranchName rejects Git-valid non-ASCII branch names before setupBranch() can check out an open PR. This affects tag mode, including PR workflows using track_progress.

This PR now focuses on the remaining Unicode support. The separately landed ASCII support (@, +, #, commas, parentheses, and leading underscores) is preserved. The latest main has been merged and conflicts resolved.

Changes

  • Allow Unicode letters and numbers, plus combining marks after the first character so decomposed accented letters and Japanese dakuten work without changing the branch name.
  • Preserve all existing reserved-pattern, control-character, option-injection, and shell-metacharacter rejection rules.
  • Add regression coverage for the exact Japanese branch reported by @aki310sony, Chinese/Cyrillic names, Unicode numbers, decomposed characters, existing ASCII punctuation combined with Unicode, and invalid names containing Unicode.

Validation

  • Reproduced the failure on the current main validator: all 9 new valid-Unicode cases failed before the fix.
  • bun test: 983 passed, 0 failed.
  • bun run typecheck: passed.
  • bun run format:check: passed.
  • Local Git smoke check: setupBranch() successfully fetched and checked out the exact reported Japanese branch for both same-repository and fork-PR paths, with a Unicode base branch.

Real repository workflow validation with the reporter and maintainer review are still pending.

@Lubrsy706

Copy link
Copy Markdown
Author

Friendly ping: this PR has been ready for review since March 6, 2026. If there is anything blocking it or if you would prefer changes before merge, let me know and I can update it. Would appreciate a review when someone has time.

@Lubrsy706 Lubrsy706 changed the title fix: allow @ and Unicode letters in branch name validation fix: allow @, +, and Unicode branch names Mar 24, 2026
@Lubrsy706

Copy link
Copy Markdown
Author

Updated this PR to include + as well. Git accepts branch names like feature+x, so the validator now allows @, +, and Unicode branch names while still rejecting reserved/unsafe patterns like @{, .lock, .., and invalid ref characters. I also added test coverage for the + case and reran the branch-name tests plus typecheck.

@Lubrsy706

Copy link
Copy Markdown
Author

Following up on this PR. The branch-name handling change should be ready for review; please let me know if you'd like any updates or additional test coverage from my side.

Lubrsy706 and others added 2 commits April 7, 2026 20:49
Update the whitelist regex in validateBranchName to support:
- `@` character (anthropics#998): valid in git branch names, only `@{` is reserved
  (already checked separately)
- Unicode letters via `\p{L}` (anthropics#1020): enables non-ASCII branch names
  like Japanese, Chinese, Cyrillic characters

Fixes anthropics#998
Fixes anthropics#1020

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Lubrsy706
Lubrsy706 force-pushed the fix/branch-name-validation-unicode-and-at branch from e6978c5 to 2fe35e5 Compare April 7, 2026 14:30
@Lubrsy706

Copy link
Copy Markdown
Author

Rebased this branch onto the latest main and resolved the merge conflicts. The branch-name validation changes now include #, @, +, and Unicode support together, and I reran bun test test/validate-branch-name.test.ts after the rebase. PR should now be conflict-free and ready for review.

@Lubrsy706

Copy link
Copy Markdown
Author

Following up on this PR. The branch-name handling fix should be ready for review; if you would like any adjustments or broader coverage for special-character branch names, I can update it. Would appreciate a review when someone has time.

@aki310sony

Copy link
Copy Markdown

Adding a data point from another affected repository, since this has been open since March.

Our branch names are Japanese by convention and this is not something we can change — they are derived from issue titles, e.g.:

feature/346-sensor_settings-isp_settings-への設定変更が値検証を通らず設定ファイルを壊せる

Every PR from such a branch fails the review job:

Error: Action failed with error: Invalid branch name: "feature/346-...".
Branch names must start with an alphanumeric character, underscore, or '@' and
contain only alphanumeric characters, forward slashes, hyphens, underscores,
periods, hashes (#), plus signs (+), commas (,), at signs (@), or parentheses.

Two observations that may help prioritise this:

The @ / + / # parts of this PR have already landed separately (#1411, #1244, #956-adjacent work), so what remains unmerged here is only the Unicode part. The whitelist has been widened one ASCII character class at a time — @, _, ,, +, parentheses — while non-ASCII, which is equally valid per git-check-ref-format, is the one case still rejected.

The comment in validateBranchName itself states the constraint is no longer needed for safety:

All git calls use execFileSync (not shell interpolation), so none of these characters carry injection risk.

The reachable path for us is setupBranch() in tag mode, which validates the head branch name unconditionally for open PRs before any git call. Our workaround is to drop track_progress so the action runs in agent mode, which does not call setupBranch() — but that also removes the tracking comment, which is where the review output was being delivered.

Happy to test a fix against real Japanese branch names if that would help.

@Lubrsy706 Lubrsy706 changed the title fix: allow @, +, and Unicode branch names fix: allow Unicode branch names Sep 21, 2026
@Lubrsy706

Copy link
Copy Markdown
Author

Thanks @aki310sony for the concrete example and offer to test. I've merged the latest main, resolved the conflicts, and updated this PR to focus on the remaining Unicode support in e6b1563. The ASCII characters and leading _ / @ already supported upstream remain accepted.

Your exact Japanese branch name is now a regression case. I also covered decomposed characters (including Japanese dakuten) and invalid Unicode-containing names without removing the existing safety checks.

Validation:

  • bun test: 983 passed, 0 failed
  • bun run typecheck and bun run format:check: passed
  • Local Git smoke checks through the actual setupBranch() path: your branch fetched and checked out successfully for both same-repository and fork PRs, with a Unicode base branch

Would you be able to test this revision in your repository with track_progress enabled? The local checks do not replace that end-to-end workflow validation. Maintainers: this is now a two-file diff against current main; I'd appreciate a review of the remaining Unicode change.

@aki310sony

aki310sony commented Sep 30, 2026 •

Copy link
Copy Markdown

@Lubrsy706 -san
Tested e6b1563 end-to-end in our repository with track_progress: true (tag mode), pinned by SHA.

On a PR from the Japanese branch feature/567-動作確認用-日本語ブランチ名でclaudeレビューが動くか, the action auto-detected tag mode, setupBranch() fetched and checked out the branch (Successfully checked out PR branch), and the review completed with the tracking comment updated as expected. No Invalid branch name error.

With the released @v1, the same setup fails on every PR from our Japanese-named branches.

Thanks for the fix — looking forward to seeing it merged.

@Lubrsy706

Lubrsy706 commented Oct 12, 2026 via email

Copy link
Copy Markdown
Author

This branch has not been deployed

No deployments
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.

validateBranchName rejects valid non-ASCII (e.g. Japanese) branch names

2 participants