Commit 896a2a7
committed
Parse API error bodies into clean bullets with did-you-mean
The CLI previously rendered 400 responses as 'API returned HTTP 400.'
with the raw JSON dump hidden behind --verbose. The server already
returns structured validation errors; this surfaces them.
errors::render_api_error now:
- Walks JSON bodies for error/errors/message/messages keys, accepting
strings, arrays of strings, arrays of objects, and nested objects.
- Treats 400/422 as 'invalid request.' with one bullet per extracted
message.
- For 'X must be one of: …' bullets, runs Levenshtein against argv and
appends a did-you-mean when the best match is within distance 3 and
shares a 3-char prefix.
- Truncates long enum lists to 5 + '(N more)'.
- Maps known field names (network, chain) to follow-up commands.
- Falls back to printing the raw body when JSON parsing fails.
- Verbose still dumps the full body.
Adds render_with_argv so the integration-test harness can use the
simulated argv instead of the test binary's process argv. 17 new unit
tests + 2 wiremock cases in tests/webhooks.rs.1 parent b0635a3 commit 896a2a7
3 files changed
Lines changed: 580 additions & 21 deletions
0 commit comments