fix(commit): --print-message failures are no longer silent (CMD-15) - #2117
Merged
Conversation
--print-message and --json share a draft-only path that logged
warnings/validationErrors through logger.verbose, which no-ops unless
--verbose is set. The exact non-interactive command the installed
prepare-commit-msg hook runs (coco commit --print-message) could exit
1 with zero output anywhere.
Routes those through logger.error instead. Plain --print-message also
gets the curated "set OPENAI_API_KEY / run coco init" missing-key hint
up front, matching every other command, instead of a bare
validationError further down. --json keeps its existing contract
(a parseable { error } payload on stdout) rather than the human-
formatted hint, since it needs stdout to stay machine-readable.
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
coco commit --print-message— the exact non-interactive command the installedprepare-commit-msghook runs on every plaingit commit— logged draft-generation warnings/validation errors throughlogger.verbose, which no-ops unless--verboseis set. A failure (e.g. missing API key) exited 1 with zero output anywhere: no stdout, no stderr, nothing.git commitwould just open an empty editor with no explanation.handleMissingApiKey(only called later, well after this early-return branch), so the curated "setOPENAI_API_KEY/ runcoco init" recovery copy every other command gets was replaced by a generic (and, per the bug above, invisible)validationErrorsstring.logger.verbose→logger.errorfor warnings/validation errors on this path, so they survive without--verbose.--print-message(not--json) now callshandleMissingApiKeyup front when the configured provider has no key, before attemptinggenerateCommitDraftat all.--jsonis left alone: it already has its own{ error }stdout contract from the existingemitJsoncall on this path, which needs to stay machine-readable rather than switching to the human-formatted hint.Closes #1888
Test plan
commit.test.ts: failures on this path now surface vialogger.error(notlogger.verbose); a missing API key shows the curated hint and skipsgenerateCommitDraftentirely;--jsonstill emits a parseable{ error }payload for the same missing-key case rather than the human-formatted hintnpx jest src/commands/commit— 252/252 passednpx tsc --noEmit -p .— cleannpx jest(full suite) — pre-existing, unrelated tree-sitter WASM failures only (same 4 failures present on a cleanorigin/maincheckout in this worktree)