From b9bc56ca980a6bdae0b16972189ffc34356bfd68 Mon Sep 17 00:00:00 2001 From: aknysh Date: Thu, 20 Aug 2026 17:56:13 -0400 Subject: [PATCH] fix: guard summary jq against null Entrypoint/Cmd/Env MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `Docker Inspect` summary step fed `.[0].Config.Entrypoint`, `.Config.Cmd`, `.Config.Env`, and `.RootFS.Layers` straight into jq's `join`/`.[]`/`to_entries`, all of which iterate their input. When an image defines no `ENTRYPOINT` (and/or no `CMD`/`ENV`), those fields are `null` in `docker inspect`, so jq aborts with: jq: error (at inspect.json:NN): Cannot iterate over null (null) Under the default `bash -e` shell that non-zero exit fails the whole `Docker Build` step (exit code 5), even though the image built and pushed fine — it only breaks the post-build job summary. Every existing test fixture is `FROM nginx`, which inherits a non-null entrypoint/cmd, so the summary path never hit a null field. Any image without an entrypoint (e.g. a plain `FROM debian:trixie-slim`) trips it. Guard each iterating expression with `// []` so null fields render as empty instead of crashing. Populated images are unaffected. Co-Authored-By: Claude Opus 4.8 (1M context) --- action.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/action.yml b/action.yml index b70d032..4a31896 100644 --- a/action.yml +++ b/action.yml @@ -275,8 +275,8 @@ runs: SIZE_MB=$(echo "scale=1; $SIZE_BYTES / 1048576" | bc) LAYER_COUNT=$(jq '.[0].RootFS.Layers | length' inspect.json) PORTS=$(jq -r '.[0].Config.ExposedPorts // {} | keys | join(", ")' inspect.json) - ENTRYPOINT=$(jq -r '.[0].Config.Entrypoint | join(" ")' inspect.json) - CMD=$(jq -r '.[0].Config.Cmd | join(" ")' inspect.json) + ENTRYPOINT=$(jq -r '(.[0].Config.Entrypoint // []) | join(" ")' inspect.json) + CMD=$(jq -r '(.[0].Config.Cmd // []) | join(" ")' inspect.json) STOP_SIGNAL=$(jq -r '.[0].Config.StopSignal // "n/a"' inspect.json) DRIVER=$(jq -r '.[0].GraphDriver.Name' inspect.json) @@ -321,7 +321,7 @@ runs: echo "" echo "| Variable | Value |" echo "|---|---|" - jq -r '.[0].Config.Env[] | split("=") | "| `\(.[0])` | `\(.[1:] | join("="))` |"' inspect.json + jq -r '(.[0].Config.Env // [])[] | split("=") | "| `\(.[0])` | `\(.[1:] | join("="))` |"' inspect.json echo "" echo "" echo "" @@ -343,7 +343,7 @@ runs: echo "" echo "| # | Digest |" echo "|---|---|" - jq -r '.[0].RootFS.Layers | to_entries[] | "| \(.key + 1) | `\(.value)` |"' inspect.json + jq -r '(.[0].RootFS.Layers // []) | to_entries[] | "| \(.key + 1) | `\(.value)` |"' inspect.json echo "" echo "" echo ""