fix(cli): recognize build/bake/builder aliasing before cloud help check - #7351
Conversation
docker-agent
left a comment
There was a problem hiding this comment.
Assessment: 🟢 APPROVE
docker --cloud build rejected every BuildKit-only flag (--secret, --ssh, --push, --output, ...) because cloudHelpRequest parsed remaining args against the legacy build command's flag set before processAliases rewrites build into a buildx invocation. Treat build/bake/builder/image build the same as plugin commands: only recognize --help/-h immediately after the resolved command path instead of validating flags. Fixes docker#7350 Signed-off-by: Nick Sieger <nick@nicksieger.com>
8e6b7f4 to
6cb63ef
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The new helper regresses valid boolean help forms such as build --help=1.
Review effort: Balanced
Findings: 1
Open (1)
What changed in this PR
Updates cloud help detection so builder aliases defer BuildKit flag parsing to buildx.
Changes:
- Detects forwarded build, bake, builder, and image build commands.
- Adds coverage for BuildKit-only flags and help requests.
| File | Description |
|---|---|
cmd/docker/cloud.go |
Handles builder aliases like plugin commands. |
cmd/docker/cloud_test.go |
Tests aliased commands and BuildKit flags. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| // isHelpFlag reports whether arg requests help, in any of the forms pflag | ||
| // accepts for a boolean flag. | ||
| func isHelpFlag(arg string) bool { | ||
| return arg == "--help" || arg == "-h" || arg == "--help=true" |
There was a problem hiding this comment.
We don't need to account for those permutations. Using --help=true on its own is already an obscure case; we only added it because technically it's allowed, but nobody uses it.
docker-agent
left a comment
There was a problem hiding this comment.
Assessment: 🟢 APPROVE
|
The e2e failure is unrelated, but looks like a genuine failure with the v29.9.0-rc.1 daemon; at a quick glance, it's either a race, or a bugfix that caused the output to change (need to check), combined with a test that may be too strict; |

Summary
docker --cloud buildrejected every BuildKit-only flag (--secret,--ssh,--push,--output, ...) becausecloudHelpRequestparsed the remaining args against the legacybuildcommand's flag set beforeprocessAliasesrewritesbuildinto abuildxinvocationbuild/bake/builder/image buildthe same as plugin commands incloudHelpRequest: only recognize--help/-himmediately after the resolved command path instead of validating flags against the legacy flag setTestCloudHelpRequestcases coveringbuild --help, BuildKit-only flags onbuild/image build/builder build, andbake --helpFixes #7350