cloudposse / cloudposse/github-action-docker-build-push
Bug: Summary step fails with "Cannot iterate over null" when image has no Cmd
- Dominant language
- Dockerfile
- Stars
- 14
- Forks
- 15
- Avg merge
- 12m
- Merged PRs (30d)
- 2
Description
## Describe the Bug
The post-build summary step fails with exit code 5 when the built Docker image has a `null` `Config.Cmd` (i.e. the image uses only an `ENTRYPOINT` and no `CMD` instruction). The image builds and pushes successfully — the failure is entirely in the summary/reporting step, but it causes the whole job to be marked as failed.
## Expected Behavior
The summary step should handle a `null` `Config.Cmd` gracefully and complete without error. Images that define only an `ENTRYPOINT` are valid Docker images and should not cause the action to fail.
## Steps to Reproduce
1. Use `cloudposse/github-action-docker-build-push@v3` with `summary: true` (the default)
2. Build a Docker image whose `Dockerfile` defines `ENTRYPOINT` but no `CMD`
3. Observe the workflow fail in the summary step after an otherwise successful build and push
## Screenshots
Logs from the failing step:
```
jq: error (at inspect.json:83): Cannot iterate over null (null)
Process completed with exit code 5.
```
The summary step runs `docker inspect` on the built image and extracts fields with `jq`. The line responsible is:
```bash
CMD=$(jq -r '.[0].Config.Cmd | join(" ")' inspect.json)
```
When `Config.Cmd` is `null`, `jq` cannot apply `join` to a null value and exits with code 5.
The suggested fix is a `// []` fallback:
```bash
CMD=$(jq -r '.[0].Config.Cmd // [] | join(" ")' inspect.json)
```
The same pattern should be applied to any other field in the summary script that assumes a non-null array (e.g. `Config.Entrypoint`).
## Environment
- Action: `cloudposse/github-action-docker-build-push@v3`
- Runner OS: `ubuntu-latest`
- Docker image: defines `ENTRYPOINT` only, no `CMD`
## Additional Context
The image inspect output confirms `"Cmd": null` in `Config`. This is valid per the Docker image spec — `CMD` is optional when `ENTRYPOINT` is set.
Contributor guide
Assessment
This issue has not been assessed yet.