Skip to content

feat: turn Command Code failures into actionable errors - #10

Merged
JoshRob297 merged 1 commit into
mainfrom
feat/actionable-errors
Oct 31, 2026
Merged

JoshRob297 merged 1 commit into
mainfrom
feat/actionable-errors

Conversation

@JoshRob297

Copy link
Copy Markdown
Owner

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

  • New src/hooks/errors.ts: errorHint() and decorateErrorBody().
  • Hints: 402 -> add credits or another account to 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.
  • Only JSON error bodies are rewritten. SSE streams, successful responses and unknown envelopes keep their bytes.
  • The HTTP status and the envelope shape are preserved, so OpenCode's retry classification is unaffected.
  • Each decoration is logged to commandcode-errors.log with status, upstream code, message and hint (no secrets).

Verify

  • bun test: 128 pass, 3 skip, 0 fail (new tests/errors.test.ts: hint mapping, envelope preservation, flat envelopes, null cases, SSE/success untouched, log written).
  • bunx tsc --noEmit: clean.

@JoshRob297
JoshRob297 changed the base branch from feat/key-rotation to main October 31, 2026 18:29
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
JoshRob297 force-pushed the feat/actionable-errors branch from 874c0d5 to 67a6e64 Compare October 31, 2026 18:29
@JoshRob297
JoshRob297 marked this pull request as ready for review October 31, 2026 18:29
@JoshRob297
JoshRob297 merged commit 757376e into main Oct 31, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant