Skip to content

Phase 1: Fix error handling bugs#28

Open
CodesMcCabe wants to merge 3 commits intomainfrom
cm/feedback
Open

Phase 1: Fix error handling bugs#28
CodesMcCabe wants to merge 3 commits intomainfrom
cm/feedback

Conversation

@CodesMcCabe
Copy link
Collaborator

@CodesMcCabe CodesMcCabe commented Mar 23, 2026

Summary

Phase 1 of the CLI feedback implementation plan — fixes the most impactful error handling bugs that erode user trust by showing misleading messages.

  • RPC error misclassification: HTTP error responses containing JSON-RPC errors (e.g. fake_method) are now correctly classified as RPC_ERROR instead of NETWORK_ERROR with "check your internet connection"
  • Invalid network errors: DNS failures from invalid --network values now say "Unknown network" with a hint to run alchemy network list, instead of a generic network error
  • RPC error hints: errRPC() now includes contextual hints for standard JSON-RPC codes (-32601 → "Method not supported", -32602 → "Invalid parameters", etc.)
  • Block validation: block -1 now rejects client-side with "Block number must be non-negative" instead of sending to RPC and getting a cryptic error
  • Unknown command messaging: alchemy abcd now says "Unknown command 'abcd'" instead of "too many arguments. Expected 0 arguments but got 1"
  • Admin API 401 vs 403: AdminClient now differentiates invalid keys (401) from access denied (403), parsing the 403 body for a reason — so valid keys hitting tier restrictions get "Access denied: ..." instead of "Invalid access key"

Test plan

  • pnpm run build passes
  • pnpm test — all 223 tests pass (7 new tests added)
  • Manual: alchemy rpc fake_method → RPC_ERROR with "Method not supported" hint
  • Manual: alchemy block -1 → INVALID_ARGS "Block number must be non-negative"
  • Manual: alchemy --network fake-network balance 0x... → INVALID_ARGS "Unknown network"
  • Manual: alchemy abcd → "Unknown command 'abcd'"

🤖 Generated with Claude Code

- RPC errors in HTTP error bodies are now correctly classified as RPC_ERROR
  instead of NETWORK_ERROR (e.g. fake_method no longer says "check your
  internet connection")
- DNS failures for invalid network slugs now report "Unknown network"
  instead of a generic network error
- errRPC() includes contextual hints for standard JSON-RPC error codes
  (-32601 "Method not supported", -32602 "Invalid parameters", etc.)
- block command validates negative numbers client-side
- Unknown CLI commands now say "Unknown command" instead of "too many
  arguments"
- AdminClient differentiates 401 (invalid key) from 403 (access denied)
  and parses the 403 response body for a reason

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@CodesMcCabe CodesMcCabe requested a review from a team as a code owner March 23, 2026 20:35
CodesMcCabe and others added 2 commits March 23, 2026 16:48
The previous approach in formatCommanderError would have rewritten ALL
"too many arguments (expected 0)" errors as "unknown command" — including
legitimate cases from zero-argument subcommands. Move the detection to
the root program action where excess args unambiguously mean an unknown
command was typed. Uses allowExcessArguments(true) so Commander doesn't
fire its own error first.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Node's fetch wraps DNS errors in a TypeError where .message is just
"fetch failed" and the actual ENOTFOUND detail is in .cause.message.
Now checks both err.message and err.cause for DNS-related patterns.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@CodesMcCabe CodesMcCabe requested a review from a team March 23, 2026 21:02
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.

2 participants