fix(cli): avoid duplicate error output in ExitNicelyOnError#6366
Open
isha822 wants to merge 1 commit intomindersec:mainfrom
Open
fix(cli): avoid duplicate error output in ExitNicelyOnError#6366isha822 wants to merge 1 commit intomindersec:mainfrom
isha822 wants to merge 1 commit intomindersec:mainfrom
Conversation
When details and message contain the same string, the CLI prints the same information twice. Added a guard so Details is only printed when it differs from Message. Also set SilenceErrors in the mindev root command to prevent Cobra from redundantly printing the error before the custom formatter.
Member
evankanderson
left a comment
There was a problem hiding this comment.
Thanks for your contribution (sorry, it got stuck behind a bunch of other PRs while I was on vacation). You'll need to sign the CLA to grant OpenSSF permissions to use your contributions before this can be merged.
Author
|
Thanks for the review! @evankanderson I've just signed the CLA. Let me know if there is anything else needed from my end to get this merged |
evankanderson
approved these changes
May 3, 2026
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.
Summary
This PR resolves an issue where the
mindevCLI outputs duplicated error messages upon command failure. Previously, theExitNicelyOnErrorutility printed identical strings for both theMessageandDetailsfields. Additionally, the Cobra framework's default error handling printed the raw error before the custom formatter executed, creating redundant terminal output.Changes introduced:
internal/util/cli/cli.goto only printDetailsif the string differs fromMessage.SilenceErrors: truein the root command (cmd/dev/app/root.go) to prevent Cobra from redundantly printing the error, deferring entirely to the custom CLI formatter.Dependencies: None
Testing
Changes were verified locally via manual CLI execution and existing unit tests.
Steps to reproduce:
go build -o bin/mindev ./cmd/dev./bin/mindev ruletype lint -r fake.yamlOutput Verification:
The CLI now outputs a single
MessageandDetailsblock without the precedingError:from Cobra or duplicated detail lines.Before:
After:
Unit Tests:
go test ./internal/util/cli/...- PASS