Skip to content

Branch name validation rejects valid git branch names containing # #1137

@pbosch

Description

@pbosch

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

  1. Create a branch with # in the name: git checkout -b "fix-arm64-#2"
  2. Push and open a PR
  3. Run claude-code-action on 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_request events where the action is reading (not creating) branches
  • Add an input to override/skip branch validation

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions