Skip to content
Latchkey

CircleCI "Context not found" / Restricted Context

A workflow references a context CircleCI cannot find or is not allowed to use, so the secrets it holds never reach the job. The name is wrong, the context belongs to another org, or a security group blocks it.

What this error means

Validation fails naming a context that "could not be found, or not authorized", or the job runs but a required env var is empty and a later step fails unauthorized. The secret was simply never injected.

circleci
Context(s) "aws-prod" not found, or not authorized for this project.
# or, at runtime:
$ aws s3 cp build/ s3://...
Unable to locate credentials. AWS_ACCESS_KEY_ID is empty.

Common causes

Name typo or wrong case

Context names are exact. AWS-Prod will not match a context named aws-prod, so it resolves to nothing.

Context from another org or never created

The context must exist in the org that owns the project. One from another org, or never created, is invisible to the pipeline.

Restricted by a security group

A restricted context only runs for an allowed group. A fork PR or unlisted user's pipeline cannot access it, so the variables stay unset.

How to fix it

Attach the correct context

.circleci/config.yml
workflows:
  deploy:
    jobs:
      - deploy:
          context:
            - aws-prod

Verify the context exists and is allowed

  1. Open Organization Settings - Contexts and confirm the exact name and case.
  2. Confirm the context belongs to the org that owns this project.
  3. If restricted, confirm the pipeline runs as an allowed user/group.

How to prevent it

  • Reference contexts by their exact lowercase name.
  • Store shared secrets in org contexts so they are reusable.
  • Add an early assertion that required env vars are non-empty.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →