Skip to content

Bug: Summary step fails with "Cannot iterate over null" when image has no Cmd #102

Description

@csteynberg

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:

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:

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug🐛 An issue with the system

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions