-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Branch name validation rejects valid git branch names containing # #1137
Description
Bug
The branch name validation regex rejects #, which is a valid character in git branch names. This causes the action to fail on PRs from branches like put-back-arm64-#2 with:
##[error] Invalid branch name: "put-back-arm64-#2". Branch names must start with an
alphanumeric character and contain only alphanumeric characters, forward slashes,
hyphens, underscores, or periods.
Context
The validation at src/github/operations/branch.ts uses regex ^[a-zA-Z0-9][a-zA-Z0-9/_.-]*$ which excludes #. Per git-check-ref-format, # is allowed in branch names.
This validation makes sense for branches the action creates, but for pull_request events where the action only reads an existing branch (checked out by actions/checkout), there's no reason to reject it. The branch already exists in git — rejecting it just prevents the review from running.
Expected behavior
For pull_request events (review mode), the action should accept whatever branch name GitHub provides via the event context, since it's already a valid git ref.
Reproduction
- Create a branch with
#in the name:git checkout -b "fix-arm64-#2" - Push and open a PR
- Run
claude-code-actionon the PR → fails with the error above
Suggested fix
Either:
- Relax the regex to allow
#and other git-valid characters - Skip branch name validation for
pull_requestevents where the action is reading (not creating) branches - Add an input to override/skip branch validation