Skip to content

fix: correct ANTHROPIC_API_KEY guard in Claude workflow (!= null!= '')#494

Merged
kimocoder merged 2 commits intomasterfrom
copilot/update-claude-workflow-robustness
Apr 13, 2026
Merged

fix: correct ANTHROPIC_API_KEY guard in Claude workflow (!= null!= '')#494
kimocoder merged 2 commits intomasterfrom
copilot/update-claude-workflow-robustness

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 13, 2026

The Claude job's if condition used != null to check for the API key, but GitHub Actions evaluates unset secrets as '' (empty string), not null. This made the guard a no-op — the job always ran, hitting the Anthropic backend and failing with "Credit balance is too low."

Changes

  • .github/workflows/claude.yml — fix job-level condition:
    # before (always true — '' != null is true)
    if: ${{ secrets.ANTHROPIC_API_KEY != null && vars.CLAUDE_CODE_ENABLED != 'false' }}
    
    # after (correctly skips job when secret is absent or empty)
    if: ${{ secrets.ANTHROPIC_API_KEY != '' && vars.CLAUDE_CODE_ENABLED != 'false' }}

The existing continue-on-error: true on the Claude step remains as a second line of defence for cases where the secret is present but the account has insufficient credits.

Original prompt

The GitHub Actions workflow in kimocoder/wifite2 is failing in the Claude Code job. The failing workflow file is .github/workflows/claude.yml.

Observed failure from logs:

  • The anthropics/claude-code-action@v1 step fails with Claude Code returned an error result: Credit balance is too low.
  • Follow-on 404 errors about branch comparison are secondary effects after the Claude action fails.

Task:

  • Create a pull request in kimocoder/wifite2 that updates .github/workflows/claude.yml to make this workflow more robust when Anthropic credentials are unavailable or unusable.
  • Prefer a minimal, safe workflow-only change.
  • The PR should prevent unnecessary hard failures of the workflow when the Claude action cannot be used.
  • Keep the existing trigger behavior unless a small adjustment is necessary for safety.

Suggested direction:

  • Add a guard so the Claude job or step only runs when secrets.ANTHROPIC_API_KEY is present.
  • If needed, make the Claude step non-blocking or otherwise avoid failing the whole workflow due to missing/unusable Claude credentials.
  • Do not make unrelated code changes.

Acceptance criteria:

  • Only workflow changes are included.
  • The resulting workflow handles missing Claude credentials gracefully.
  • The change is minimal and clearly explained in the PR description/title.
  • A pull request is opened against the repository with the fix.

The following is the prior conversation context from the user's chat exploration (may be truncated):

User: Fix the workflow issue from logs

Assistant: I’ve identified the failure and submitted the workflow change; once you respond to the pending confirmation dialog, I can continue and verify the result.

User: @copilot Accepted Confirmation: Are you sure?

Assistant: The workflow itself isn’t broken by YAML syntax — it’s failing because the Claude action is actually running and the backend returns “Credit balance is too low.”

Root cause

  • The failing step is anthropics/claude-code-action@v1.
  • The log shows: Claude Code returned an error result: Credit balance is too low.
  • The later 404s for claude/issue-484-20260413-2136 are secondary: the branch was never created because the action failed first.

What to fix
You have two practical options:

  1. Fund / replace the Anthropic API key in ANTHROPIC_API_KEY

    • Best if you want this workflow to keep working.
  2. Guard or disable the workflow so it doesn’t fail when credits are unavailable

    • Best if this repo shouldn’t hard-fail on Claude reviews.

Recommended workflow change
Add a job-level guard so the job only runs when the secret exists, and optionally make the workflow manual-only if you don’t want comment-triggered failures.

Your current file:

name: Claude Code

on:
  issue_comment:
    types: [created]
  pull_request_review_comment:
    types: [created]

jobs:
  claude:
    runs-on: ubuntu-latest
    permissions:
      id-token: write
      contents: write
      pull-requests: write
      issues: write

    steps:
      - name: Checkout repo
        uses: actions/checkout@v6.0.2

      - name: Run Claude Code Action
        uses: anthropics/claude-code-action@v1
        with:
          anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}

          # What Claude should do
          prompt: |
            You are an expert security researcher reviewing changes to wifite2 (a Python WiFi auditing tool).
            Review this pull request or comment for:
            - bugs
            - security issues
            - code quality problems
            - performance improvements
            Focus especially on Python code. Be concise but thorough. If you can fix something, do it.

          claude_args: |
            --max-turns 8

          # Optional but very useful
          trigger_phrase: "@claude"
          use_sticky_comment: true
          include_fix_links: true
          track_progress: true

Suggested minimal change:

name: Claude Code

on:
  issue_comment:
    types: [created]
  pull_request_review_comment:
    types: [created]

jobs:
  claude:
    if: ${{ secrets.ANTHROPIC_API_KEY != '' }}
    runs-on: ubuntu-latest
    permissions:
      id-token: write
      contents: write
      pull-requests: write
      issues: write

    steps:
      - name: Checkout repo
        uses: actions/checkout@v6.0.2

      - name: Run Claude Code Action
        uses: anthropics/claude-code-action@v1
        with:
          anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
          prompt: |
            You are an expert security researcher reviewing changes to wifite2 (a Python WiFi auditing tool).
            Review this pull request or comment for:
            - bugs
            - security issues
            - code quality problems
            - per...

</details>



<!-- START COPILOT CODING AGENT SUFFIX -->

*This pull request was created from Copilot chat.*
>

Copilot AI changed the title [WIP] Update Claude workflow for enhanced robustness with missing credentials fix: correct ANTHROPIC_API_KEY guard in Claude workflow (!= null!= '') Apr 13, 2026
Copilot AI requested a review from kimocoder April 13, 2026 21:41
@kimocoder kimocoder marked this pull request as ready for review April 13, 2026 21:42
Copilot AI review requested due to automatic review settings April 13, 2026 21:42
@kimocoder kimocoder merged commit fc243d2 into master Apr 13, 2026
12 of 14 checks passed
@kimocoder kimocoder deleted the copilot/update-claude-workflow-robustness branch April 13, 2026 21:42
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adjusts the Claude GitHub Actions workflow guard so the Claude job is skipped when ANTHROPIC_API_KEY is unset/empty, preventing unnecessary calls to Anthropic (and the resulting “Credit balance is too low” failures) when credentials aren’t available.

Changes:

  • Update the Claude job-level if condition to check secrets.ANTHROPIC_API_KEY != '' instead of != null.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

3 participants