Skip to content
Latchkey

GitHub Actions Secret Empty or "Context access might be invalid"

A secret reference resolves to an empty string because the name is wrong, the secret lives at a scope this job cannot see, or it is referenced where the secrets context is unavailable.

What this error means

A step using secrets.<NAME> behaves as if the value is blank, and downstream auth fails. The editor may warn "Context access might be invalid" for the secret name.

Actions log
Error: missing API key
# secrets.API_KEY came through empty
Warning: Context access might be invalid: API_KEY

Common causes

Name or scope mismatch

Secret names are case-sensitive and scoped. A repo secret is not visible if the job expects an environment secret, and an org secret may not be shared with this repo.

Referenced where secrets are unavailable

The secrets context is not available in some keys (like runs-on or a reusable-workflow uses line), so the reference silently yields nothing.

How to fix it

Define the secret at the scope the job uses

  1. Add the secret under the right scope: repo, environment (with environment: set on the job), or org with access to this repo.
  2. Match the exact case of the secret name.
  3. For reusable workflows, pass secrets explicitly or with secrets: inherit.

Reference secrets only where allowed

Use secrets in step env or with, not in keys evaluated before the job context exists.

.github/workflows/deploy.yml
jobs:
  deploy:
    environment: production
    steps:
      - run: ./deploy.sh
        env:
          API_KEY: ${{ secrets.API_KEY }}

How to prevent it

  • Keep a single, documented scope for each secret.
  • Set environment: on jobs that consume environment secrets.
  • Forward secrets explicitly to reusable workflows.

Frequently asked questions

What causes "Secret empty/undefined"?
Secret names are case-sensitive and scoped. A repo secret is not visible if the job expects an environment secret, and an org secret may not be shared with this repo.
How do I fix Secret empty/undefined?
Define the secret at the scope the job uses

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card