SAM Doctor

ERROR REFERENCE

Unable to upload artifact referenced by CodeUri

A CodeUri, ContentUri, or DefinitionUri in the template points at a path that does not exist where the deploy ran. The classic cause: deploying before sam build, or deploying the source template instead of the built one.

WHAT IT MEANS

What this error means

The template is fine and AWS was never the problem - the referenced path simply is not there. In CI this usually means the build step did not run, ran in a different working directory, or its output was not carried into the job that deploys.

FIX

How to fix it

  1. Build, then deploy the built template:
    sam build
    sam deploy   # uses .aws-sam/build/template.yaml automatically
    Passing -t template.yaml to deploy after building reintroduces the source paths and this error with it.
  2. In CI, keep build and deploy in one job and one directory — or explicitly hand the .aws-sam/build/ output between jobs as an artifact.
  3. Verify the path exists where the deploy runs:
    ls .aws-sam/build/ && ls .aws-sam/build/template.yaml

AUTOMATE THE TRIAGE

Diagnose this automatically

SAM Doctor recognizes both phrasings (high confidence) and separates this local-path failure from the S3 access failures it superficially resembles. Runs locally; no AWS access, no log upload.

python -m pip install sam-doctor
sam-doctor diagnose deployment.log --format markdown

RELATED