Skip to content

fix(compose): reject unknown subcommands under bridge/transformations - #14143

Merged
ndeloof merged 1 commit into
docker:mainfrom
glours:fix/bridge-unknown-subcommand-exit-code
Aug 31, 2026
Merged

fix(compose): reject unknown subcommands under bridge/transformations#14143
ndeloof merged 1 commit into
docker:mainfrom
glours:fix/bridge-unknown-subcommand-exit-code

Conversation

@glours

@glours glours commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

What I did
bridgeCommand and transformersCommand had no RunE, so an unknown subcommand (e.g. "bridge zzz") fell through cobra's default non-Runnable path: help printed, exit 0. Scripts couldn't distinguish a typo from success. Mirrors the same fix already shipped on the compose root command.

Related issue
https://docker.atlassian.net/browse/DDB-666

(not mandatory) A picture of a cute animal, if possible in relation to what you did
image

@glours
glours requested review from a team as code owners August 27, 2026 13:00
@glours
glours requested a review from ndeloof August 27, 2026 13:00
@glours glours self-assigned this Aug 27, 2026

@docker-agent docker-agent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assessment: 🟢 APPROVE

The PR correctly wires rejectUnknownSubcommand as RunE on the bridgeCommand and transformersCommand parent commands so that unknown subcommands exit 1 instead of 0. The core logic is sound: cobra dispatches unknown tokens to the parent's RunE, known subcommands are dispatched directly so the new guard is never incorrectly invoked, and the tests cover all the key scenarios (unknown subcommand, no subcommand, nested transformations).

One low-severity finding below: a discarded cmd.Help() error in the non-zero-args path.

Comment thread cmd/compose/bridge.go
@codecov

codecov Bot commented Aug 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

bridgeCommand and transformersCommand had no RunE, so an unknown
subcommand (e.g. "bridge zzz") fell through cobra's default
non-Runnable path: help printed, exit 0. Scripts couldn't distinguish
a typo from success. Mirrors the same fix already shipped on the
compose root command.

Signed-off-by: Guillaume Lours <glours@users.noreply.github.com>
@glours
glours force-pushed the fix/bridge-unknown-subcommand-exit-code branch from d382891 to dcea158 Compare August 27, 2026 13:14
@ndeloof
ndeloof merged commit e7c766f into docker:main Aug 31, 2026
94 of 95 checks passed
@ndeloof
ndeloof deleted the fix/bridge-unknown-subcommand-exit-code branch August 31, 2026 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants