Skip to content

fix: remove misleading error prefix for exit-code#191

Merged
btwshivam merged 4 commits into
optiqor:mainfrom
qrstajalli:fix-exit-code-error
Jun 7, 2026
Merged

fix: remove misleading error prefix for exit-code#191
btwshivam merged 4 commits into
optiqor:mainfrom
qrstajalli:fix-exit-code-error

Conversation

@qrstajalli
Copy link
Copy Markdown
Contributor

Removed the misleading "Error:" prefix from CLI output when using --exit-code.

This ensures expected critical findings are displayed cleanly without being framed as unexpected errors.

Fixes #122

@qrstajalli qrstajalli requested a review from btwshivam as a code owner June 6, 2026 14:25
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 6, 2026

🚀 First PR — welcome aboard!

A few things to expect:

  1. CI: every PR runs build + race tests + lint + (eventually) the kernel matrix. If something fails, the log will tell you exactly which gate.
  2. DCO: every commit needs Signed-off-by:git commit -s adds it automatically.
  3. Conventional Commits: PR titles like feat(doctor): add new rule or fix(bpf): handle X. We squash-merge by default.
  4. Review: a maintainer will review within 72 hours. Suggestions are conversations, not orders — push back if something doesn't fit your context.

If you get stuck, reply here or jump to Discussions. We want this PR to land.

@github-actions github-actions Bot added the level:intermediate 50-200 lines or 3-5 files (auto-applied) label Jun 6, 2026
Copy link
Copy Markdown
Member

@btwshivam btwshivam left a comment

Choose a reason for hiding this comment

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

dropping the prefix doesn't fix the issue.. a clean --exit-code run still writes the exitError message to stderr and ExitCode() stays dead..

Comment thread cmd/kerno/main.go Outdated
func main() {
if err := cli.New().Execute(); err != nil {
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
fmt.Fprintln(os.Stderr, err)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this still prints the exitError message to stderr on an expected --exit-code outcome, just without the Error: prefix. #122 asks to type-assert interface{ ExitCode() int }, exit with that code and skip the message, or drop the unused ExitCode(). a non-exitError still needs an Error: line, so a blanket Fprintln also regresses real errors.

Copy link
Copy Markdown
Member

@btwshivam btwshivam left a comment

Choose a reason for hiding this comment

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

thanks, this is the right fix now, main type-asserts ExitCode() and skips the Error line for the expected exit-code outcome.

@btwshivam
Copy link
Copy Markdown
Member

/lgtm

@btwshivam btwshivam merged commit b1aef21 into optiqor:main Jun 7, 2026
17 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

level:intermediate 50-200 lines or 3-5 files (auto-applied)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(cli): --exit-code prints spurious Error line on critical finding

2 participants