Repository navigation
exit 1 when a command fails, and print the error once - #1249
Merged
Merged
Conversation
With Apple's container CLI missing, `onctl -p ac claude` printed the error twice -- cobra's "Error:" with the whole usage text, as if it were a typo, then main's log line -- and exited 0; `onctl -p ac ls` logged it, printed an empty table and exited 0, so a script read "no VMs". The cause was general: main logged Execute's error and returned, and ls never returned one. main exits 1 on an error. The root command silences cobra's usage and error printing, so a run-time failure is main's one line; a bad flag keeps a pointer to the usage (flagError: "Run 'onctl claude --help' for usage."). ls returns the provider's error after showing what the other call did return, as listVMs intends. Claude-Session: https://claude.ai/code/session_01FGfFdYSzrrKe3ySAVMPSNR
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1249 +/- ##
==========================================
+ Coverage 47.57% 47.77% +0.19%
==========================================
Files 81 81
Lines 9341 9342 +1
==========================================
+ Hits 4444 4463 +19
+ Misses 4897 4879 -18 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Found while testing
onctl -p acwithout Apple's container CLI: the message was right, butonctl -p ac claudeprinted it twice -- cobra'sError:plus the whole usage text, as if it were a typo, then main's log line -- and exited 0;onctl -p ac lslogged it, printed an empty table and exited 0, so a script read "no VMs".The cause is general, not ac's:
mainloggedExecute's error and returned, andlsnever returned one.Changes:
main.go:os.Exit(1)after logging the error.rootCmd:SilenceUsageandSilenceErrors, so a run-time failure is main's one line. A bad flag keeps a pointer to the usage throughflagError:unknown flag: --kep/Run 'onctl claude --help' for usage.ls:RunE, returning the provider's error after printing what the other call did return (aslistVMsintends).Checked by hand with the CLI path pointed at a missing binary: claude and ls exit 1 with one error line, an unknown flag exits 1 with the hint, a working
lsstill exits 0. Tests:TestListCmd_ProviderErrorIsTheResult,TestRootErrorsPrintOnce.🤖 Generated with Claude Code
https://claude.ai/code/session_01FGfFdYSzrrKe3ySAVMPSNR