Commit Graph

1 Commits

Author SHA1 Message Date
Nicolò Boschi 737e5bf420 fix(cli): print the server's response body on API errors (#4049) (#4113)
`hindsight document get <bank> <missing-id>` reported "API endpoint not
found (404)" with endpoint-path/version guidance, while the server had
answered 404 `{"detail":"Document not found"}` — pointing the operator at
an API breakage instead of an absent document.

Two things were dropping the body:

- `api.rs` only ran three of ~70 generated-client calls through
  `humanize_client_error`; the rest used a bare `.await?`, so the error
  rendered via progenitor's `Display` as a body-less "Unexpected
  Response: Response { .. }" and the body was never read at all. Every
  call now goes through a `Humanized` extension trait on the call future
  (`call(..).humanized().await?`), which attaches status and body.
- `errors.rs` discarded the body in the 404/401/403/5xx branches.
  `server_detail` now pulls the JSON `detail` (or the raw body) out of
  the error and every branch surfaces it: a 404 that explains itself
  prints "Not found (404): Document not found", and only a bodyless 404
  — a genuine unknown route — keeps the path/version guidance.

Nothing in the type system stops the next call site from writing the
bare form, and no unit test exercises a real error response, so
`tests/api_error_surface.rs` checks the whole family: every statement in
`api.rs` that awaits a generated-client call must end in `.humanized()`.
2026-09-04 11:17:27 +02:00