Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

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

未关闭 适合新手
#102 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
72/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
冷清
技术栈
docker, dockerfile
领域
ci-cd, devops

调研方向

从运行 docker inspect 的摘要脚本以及读取 Config.Cmd 的 jq 表达式开始;issue 中已确定 inspect.json 和失败的 join(\" \") 表达式。让摘要能够容忍 null 数组字段,包括 Config.Cmd 和可能存在的 Config.Entrypoint,然后验证带有 ENTRYPOINT 但没有 CMD 的镜像能够成功完成。

由索引模型根据 Issue 内容生成。

描述

bug

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.

主要语言
Dockerfile
星标
14
派生
15
平均合并
8 小时 45 分钟
30 天内合并 PR
1

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

cloudposse/github-action-docker-build-push 的其他 Issue

查看 cloudposse/github-action-docker-build-push 的全部 Issue

相似的 Issue

更多 DevOps Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。