Skip to content

fix: error response body - #20

Merged
EvilFreelancer merged 1 commit into
EvilFreelancer:mainfrom
itsyoboieltr:fix/error-response-body
Aug 21, 2026
Merged

fix: error response body#20
EvilFreelancer merged 1 commit into
EvilFreelancer:mainfrom
itsyoboieltr:fix/error-response-body

Conversation

@itsyoboieltr

@itsyoboieltr itsyoboieltr commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Problem

When a request fails, the CLI only printed axios's default message:

Request failed with status code 400

That's not enough to act on. In practice, the useful part of an HTTP error is almost always in the response body, like validation errors (field email must be unique), auth errors (token expired), server errors with tracebacks, etc. Without it, you're left guessing what the server objected to.

This matters most for agent-driven usage: an agent that hits a 400/422/500 needs the body to diagnose and self-correct (fix the payload, retry with a different value, stop). Today it gets a status code and nothing else, so it can't debug the failure at all, it can only retry blindly or give up.

Change

In runApiCommand, catch request errors and, when the error carries a response body, append it (pretty-printed) to the error message:

Request failed with status code 400
{
  "message": "invalid input"
}
  • Uses instanceof AxiosError, only real axios errors are affected, everything else is rethrown unchanged.
  • String bodies (plain text, HTML) are printed verbatim, JSON bodies are pretty-printed.
  • Errors without a response (network failures, timeouts) behave exactly as before.

@itsyoboieltr itsyoboieltr changed the title Include response body in error output for failed requests fix: error response body Aug 20, 2026
@EvilFreelancer
EvilFreelancer merged commit 507bb51 into EvilFreelancer:main Aug 21, 2026
1 check passed
@EvilFreelancer

Copy link
Copy Markdown
Owner

Hi @itsyoboieltr! Thanks for your PR, it was merged and released as v0.1.19

@itsyoboieltr
itsyoboieltr deleted the fix/error-response-body branch September 3, 2026 23:09
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