Repository navigation
feat: turn Command Code failures into actionable errors - #10
Merged
Merged
Conversation
JoshRob297
force-pushed
the
feat/key-rotation
branch
from
October 31, 2026 18:28
547ba09 to
39d7271
Compare
Keep the HTTP status and the JSON envelope, but append a resolution hint: add credits or another key for 402, pick another model or upgrade for MODEL_NOT_IN_PLAN, replace or rotate for 401/403, wait or rotate for 429, and the Anthropic-surface note for unsupported_model. Only JSON error bodies are touched (SSE and successes keep their bytes) and the status is never rewritten, so OpenCode's retry classification is unaffected.
JoshRob297
force-pushed
the
feat/actionable-errors
branch
from
October 31, 2026 18:29
874c0d5 to
67a6e64
Compare
JoshRob297
marked this pull request as ready for review
October 31, 2026 18:29
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.
Stacked on #9 (key rotation), which is stacked on #8 (ZDR). Rebase to main once both merge.
Context
Command Code returns failures like
You have insufficient credits...,MODEL_NOT_IN_PLAN...or a bare 429 to OpenCode, which shows them verbatim. The user does not learn the one thing that matters: what to do next.Change
src/hooks/errors.ts:errorHint()anddecorateErrorBody().COMMANDCODE_API_KEYS;MODEL_NOT_IN_PLAN-> pick another model or upgrade; 401/403 -> replace or rotate the key; 429/window -> wait or rotate;unsupported_model-> Anthropic-shaped, only on/messages.commandcode-errors.logwith status, upstream code, message and hint (no secrets).Verify
bun test: 128 pass, 3 skip, 0 fail (newtests/errors.test.ts: hint mapping, envelope preservation, flat envelopes, null cases, SSE/success untouched, log written).bunx tsc --noEmit: clean.