Skip to content

cmd/docker: setFlagErrorFunc: don't load plugins for invalid flags - #6526

Merged
vvoland merged 2 commits into
docker:masterfrom
thaJeztah:no_plugin_load
Oct 3, 2025
Merged

cmd/docker: setFlagErrorFunc: don't load plugins for invalid flags#6526
vvoland merged 2 commits into
docker:masterfrom
thaJeztah:no_plugin_load

Conversation

@thaJeztah

@thaJeztahthaJeztah commented Sep 30, 2025

Copy link
Copy Markdown
Member

relates to:

cmd/docker: setFlagErrorFunc: don't load plugins for invalid flags

On Docker CLI versions before v28.0.0, using an unknown flag would print
the usage output, showing all available top-level flags and commands;

docker --badopt
unknown flag: --badopt
See 'docker --help'.
Usage: docker [OPTIONS] COMMAND
A self-sufficient runtime for containers
Options:
--config string Location of client config files (default "/root/.docker")
...

This output did not include plugin-commands, making the usage output
incomplete. That issue was fixed in cli@40a6cf7, which loaded all
available cli-plugins, so that a stub was created for printing the
plugin commands in the usage output. Similarly, cli@79a75da added
code to hide experimental commands and commands not supported by the
daemon.

However, since 28.0.0 (commit cli@f28fc7f), the usage output was
removed for this error, so loading plugins is no longer needed;

docker --badopt
unknown flag: --badopt
Usage: docker [OPTIONS] COMMAND [ARG...]
Run 'docker --help' for more information

This patch removes the code added in cli@40a6cf7 and cli@79a75da.

With this patch, the output is still the same;

docker --unknown-flag buildx ls --no-such
unknown flag: --unknown-flag
Usage: docker [OPTIONS] COMMAND [ARG...]
Run 'docker --help' for more information

This function only handles flags defined by the CLI itself; invalid
flags for plugins are handled by the plugin itself, so are not
impacted;

docker buildx ls --no-such
unknown flag: --no-such
Usage: docker buildx ls
Run 'docker buildx ls --help' for more information

- What I did

- How I did it

- How to verify it

- Human readable description for the release notes

- A picture of a cute animal (not mandatory but encouraged)

@thaJeztahthaJeztah added this to the 29.0.0 milestone Sep 30, 2025
@codecov-commenter

codecov-commenter commented Sep 30, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.

Files with missing linesPatch %Lines
cmd/docker/docker.go0.00%2 Missing ⚠️

📢 Thoughts on this report? Let us know!

On Docker CLI versions before v28.0.0, using an unknown flag would print
the usage output, showing all available top-level flags and commands;
docker --badopt
unknown flag: --badopt
See 'docker --help'.
Usage: docker [OPTIONS] COMMAND
A self-sufficient runtime for containers
Options:
--config string Location of client config files (default "/root/.docker")
...
This output did not include plugin-commands, making the usage output
incomplete. That issue was fixed in [cli@40a6cf7], which loaded all
available cli-plugins, so that a stub was created for printing the
plugin commands in the usage output. Similarly, [cli@79a75da] added
code to hide experimental commands and commands not supported by the
daemon.
However, since 28.0.0 (commit [cli@f28fc7f]), the usage output was
removed for this error, so loading plugins is no longer needed;
docker --badopt
unknown flag: --badopt
Usage: docker [OPTIONS] COMMAND [ARG...]
Run 'docker --help' for more information
This patch removes the code added in [cli@40a6cf7] and [cli@79a75da].
With this patch, the output is still the same;
docker --unknown-flag buildx ls --no-such
unknown flag: --unknown-flag
Usage: docker [OPTIONS] COMMAND [ARG...]
Run 'docker --help' for more information
This function only handles flags defined by the CLI itself; invalid
flags for plugins are handled by the plugin itself, so are not
impacted;
docker buildx ls --no-such
unknown flag: --no-such
Usage: docker buildx ls
Run 'docker buildx ls --help' for more information
[cli@f28fc7f]: docker@f28fc7f
[cli@40a6cf7]: docker@40a6cf7
[cli@79a75da]: docker@79a75da
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@thaJeztah

Copy link
Copy Markdown
MemberAuthor

LOL; and all of a sudden, the linter starts to flag unrelated code;

70.72 cmd/docker/docker.go:560:74: hideUnsupportedFeatures - result 0 (error) is always nil (unparam)
70.72 func hideUnsupportedFeatures(cmd *cobra.Command, details versionDetails) error {
70.72 ^
70.72 1 issues:

```
70.72 cmd/docker/docker.go:560:74: hideUnsupportedFeatures - result 0 (error) is always nil (unparam)
70.72 func hideUnsupportedFeatures(cmd *cobra.Command, details versionDetails) error {
70.72 ^
70.72 1 issues:
```
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@vvoland
vvoland merged commit 780c427 into docker:masterOct 3, 2025
86 checks passed
@thaJeztah
thaJeztah deleted the no_plugin_load branch October 3, 2025 14:06
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/performancekind/refactorPR's that refactor, or clean-up codestatus/2-code-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@thaJeztah@codecov-commenter@vvoland