aws / aws/aws-sam-cli

Bug: Missing DockerContext doesn't fail validation

Open
#7,017 3 comments 0 reactions 0 assignees View on GitHub
type/feedback
Dominant language
Python
Stars
6.7k
Forks
1.2k
Avg merge
1d 10h
Merged PRs (30d)
52

Description

### Description:

If you set `Dockerfile` in a function's metadata, but _not_ `DockerContext`, `sam build` seems to just work, except then `sam local invoke` complains `Error: ImageUri not provided for Function: YourFunctionName of PackageType: Image` which is very confusing. Note also `sam validate` doesn't complain abou this.

### Steps to reproduce:

Create a correct docker image SAM template, then remove just the `DockerContext` metadata param.

### Observed result:
`sam local invoke` fails with a confusing error

### Expected result:
`sam validate` fails, or maybe `sam build`?

### Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

1. OS: MacOS
2. `sam --version`: 1.116.0

```
{
"version": "1.116.0",
"system": {
"python": "3.11.6",
"os": "macOS-14.0-arm64-arm-64bit"
},
"additional_dependencies": {
"docker_engine": "23.0.6",
"aws_cdk": "Not available",
"terraform": "1.4.1"
},
"available_beta_feature_env_vars": [
"SAM_CLI_BETA_FEATURES",
"SAM_CLI_BETA_BUILD_PERFORMANCE",
"SAM_CLI_BETA_TERRAFORM_SUPPORT",
"SAM_CLI_BETA_RUST_CARGO_LAMBDA"
]
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.