fix(hooks): ensure command errors are displayed before CLI hooks#7071
Open
mohithshuka wants to merge 2 commits into
Open
fix(hooks): ensure command errors are displayed before CLI hooks#7071mohithshuka wants to merge 2 commits into
mohithshuka wants to merge 2 commits into
Conversation
added 2 commits
June 14, 2026 16:55
The --filter flag description for 'docker volume prune' only mentioned 'label=<label>' but not 'label!=<label>', even though the label! filter is supported and handled correctly by the underlying PruneFilters function. This commit: - Updates the --filter flag description to include label!=<label> - Adds a unit test for the label! filter to match the existing label filter test Fixes docker#6918 Signed-off-by: mohithshuka <YOUR_ID+mohithshuka@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR aims to improve CLI UX by ensuring command failure errors are displayed before any “What’s next” (CLI hook) output, preventing hooks from visually preceding the actual error message.
Changes:
- Adjusts the
runDocker()execution flow to print command errors before running CLI command hooks. - Updates
docker volume prunehelp text to mentionlabel!=...filters. - Adds a
label!=...test-case and golden output forvolume prune.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
cmd/docker/docker.go |
Attempts to change the ordering between command errors and CLI hooks (currently introduces a compilation issue). |
cli/command/volume/prune.go |
Expands filter help text to include label!=<label>. |
cli/command/volume/prune_test.go |
Adds coverage for --filter label!=... behavior. |
cli/command/volume/testdata/volume-prune-success.label-not-filter.golden |
Adds golden output for the new label-not-filter test case. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
546
to
550
| // If the command is being executed in an interactive terminal | ||
| // and hook are enabled, run the plugin hooks. | ||
| if subCommand != nil && dockerCli.Out().IsTerminal() && dockerCli.HooksEnabled() { | ||
| if subCommand != nil && dockerCli.Out().IsTerminal() && dockerCli.HooksEnabled() _ = dockerCli.Err().Flush(){ | ||
| pluginmanager.RunCLICommandHooks(ctx, dockerCli, cmd, subCommand, cmdErrorMessage(err)) | ||
| } |
Comment on lines
58
to
61
| flags.SetAnnotation("all", "version", []string{"1.42"}) | ||
| flags.BoolVarP(&options.force, "force", "f", false, "Do not prompt for confirmation") | ||
| flags.Var(&options.filter, "filter", `Provide filter values (e.g. "label=<label>")`) | ||
| flags.Var(&options.filter, "filter", `Provide filter values (e.g. "label=<label>" or "label!=<label>")`) | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes the ordering of CLI hook output and command errors.
Currently, when a command fails, the "What's next" hook message is printed
before the actual error, which can confuse users.
Changes
Ensure command errors are displayed before CLI hooks.
Preserve the existing hook functionality.
Improve the readability of CLI output in failure scenarios.
Reviewed the execution flow of
runDocker()Verified that command errors are emitted before hook output
No changes to public APIs
Fixes #6973