-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Open
Labels
bugSomething isn't workingSomething isn't workingp2Non-showstopper bug or popular feature requestNon-showstopper bug or popular feature request
Description
Bug
When claude-code-action runs on a repository whose default branch is master (or anything other than main), the config restore step fails with:
fatal: couldn't find remote ref main
Error: Action failed with error: Command failed: git fetch origin main --depth=1
This happens because baseBranch falls back to hardcoded "main" in several places when no explicit base_branch input is provided.
Affected locations
| File | Line(s) | Code |
|---|---|---|
src/modes/agent/index.ts |
~89, ~96 | process.env.BASE_BRANCH || context.inputs.baseBranch || "main" |
src/entrypoints/run.ts |
~315 | baseBranch || "main" |
src/entrypoints/update-comment-link.ts |
~256 | process.env.BASE_BRANCH || "main" |
Expected behavior
When base_branch is not provided, the action should detect the repository's actual default branch instead of assuming "main".
The fix already exists in the codebase
src/github/operations/branch.ts (~line 185) already implements the correct pattern:
const repoResponse = await octokits.rest.repos.get({ owner, repo });
sourceBranch = repoResponse.data.default_branch;Alternatively, ${{ github.event.repository.default_branch }} is available in the Actions context and could be used as the fallback instead of hardcoding "main".
Workaround
Callers can pass base_branch explicitly:
- uses: anthropics/claude-code-action@v1
with:
base_branch: ${{ github.event.repository.default_branch }}Reproduction
- Use
claude-code-action@v1on a repo whose default branch ismaster - Trigger via PR comment
- Action fails at the config restore step before Claude even runs
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingp2Non-showstopper bug or popular feature requestNon-showstopper bug or popular feature request