Skip to content

fix: allow '#' in branch names for Azure DevOps integration#1032

Open
MaxwellCalkin wants to merge 1 commit intoanthropics:mainfrom
MaxwellCalkin:fix/allow-hash-in-branch-names
Open

fix: allow '#' in branch names for Azure DevOps integration#1032
MaxwellCalkin wants to merge 1 commit intoanthropics:mainfrom
MaxwellCalkin:fix/allow-hash-in-branch-names

Conversation

@MaxwellCalkin
Copy link

Summary

  • Fixes branch name validation rejecting the # character, which breaks Azure DevOps integration where branch names commonly include work item references (e.g., feature/AB#1992-sentry-enhancements)
  • Updates the whitelist regex pattern from [a-zA-Z0-9/_.-] to [a-zA-Z0-9/_#.-]
  • Adds test cases covering branch names with # characters

Details

The # character is valid in git branch names and poses no command injection risk (it's a comment character in shell but execFileSync is used, which bypasses shell interpretation). Azure DevOps automatically creates branch names containing # when linking branches to work items.

Changed files:

  • src/github/operations/branch.ts — Added # to the valid character whitelist pattern and updated comments/error message
  • test/validate-branch-name.test.ts — Added test case for hash-containing branch names

Fixes #1024

Test plan

  • All 31 existing + new branch validation tests pass (bun test test/validate-branch-name.test.ts)
  • New test covers Azure DevOps-style branch names: feature/AB#1992-sentry-enhancements, fix/PROJ#123-bug, user/task#42
  • No other validation rules were modified — all security checks (command injection, option injection, path traversal) remain intact

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com

The branch name validation regex rejected the '#' character, which is
commonly used in Azure DevOps branch naming conventions (e.g.,
"feature/AB#1992-sentry-enhancements"). The '#' character is valid in
git branch names and poses no command injection risk.

Updated the whitelist pattern to include '#' and added corresponding
test cases.

Fixes anthropics#1024

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

Branch name validation rejects '#' character, breaking Azure DevOps integration

1 participant