Skip to content

fix: fall back to inherited env for auth when inputs are empty#1342

Open
kirsanium wants to merge 1 commit into
anthropics:mainfrom
kirsanium:fix/oauth-token-env-fallback
Open

fix: fall back to inherited env for auth when inputs are empty#1342
kirsanium wants to merge 1 commit into
anthropics:mainfrom
kirsanium:fix/oauth-token-env-fallback

Conversation

@kirsanium
Copy link
Copy Markdown

The "Run Claude Code Action" step maps the auth inputs into env unconditionally:

ANTHROPIC_API_KEY: ${{ inputs.anthropic_api_key }}
CLAUDE_CODE_OAUTH_TOKEN: ${{ inputs.claude_code_oauth_token }}

When the input is empty — whether because the caller supplied auth via the step env: block (as reported in #676) or because the with: value resolves empty in some runner/secret configurations — this assignment overwrites the inherited env value with an empty string. validate-env then fails with the misleading "Either ANTHROPIC_API_KEY or CLAUDE_CODE_OAUTH_TOKEN is required" error even though the caller did provide a token.

Fall back to the inherited env var when the input is empty, mirroring the existing ${{ env.X }} pattern already used a few lines below for ANTHROPIC_BASE_URL / ANTHROPIC_CUSTOM_HEADERS. The input still takes precedence; nothing changes for workflows that pass auth via with:.

Fixes #676

The "Run Claude Code Action" step maps the auth inputs into env
unconditionally:

    ANTHROPIC_API_KEY: ${{ inputs.anthropic_api_key }}
    CLAUDE_CODE_OAUTH_TOKEN: ${{ inputs.claude_code_oauth_token }}

When the input is empty — whether because the caller supplied auth via
the step `env:` block (as reported in anthropics#676) or because the `with:` value
resolves empty in some runner/secret configurations — this assignment
overwrites the inherited env value with an empty string. validate-env
then fails with the misleading "Either ANTHROPIC_API_KEY or
CLAUDE_CODE_OAUTH_TOKEN is required" error even though the caller did
provide a token.

Fall back to the inherited env var when the input is empty, mirroring the
existing `${{ env.X }}` pattern already used a few lines below for
ANTHROPIC_BASE_URL / ANTHROPIC_CUSTOM_HEADERS. The input still takes
precedence; nothing changes for workflows that pass auth via `with:`.

Fixes anthropics#676
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.

CLAUDE_CODE_OAUTH_TOKEN is cleared between prepare and execute phases, causing authentication failure

1 participant