Skip to content

Show the server request id on non-2xx responses#17

Merged
hbrooks merged 1 commit into
mainfrom
show-request-id-on-error
Jun 30, 2026
Merged

Show the server request id on non-2xx responses#17
hbrooks merged 1 commit into
mainfrom
show-request-id-on-error

Conversation

@hbrooks

@hbrooks hbrooks commented Jun 30, 2026

Copy link
Copy Markdown
Member

What

When an API call fails, agent now prints the server's per-request id so a user can quote it and we can map the failure to an exact log line.

Before:

error: POST /v1/agents/runs failed: 500 Internal Server Error

After:

error: POST /v1/agents/runs failed: 500 Internal Server Error (request id: request_IRig...KV1r)

Pairs with the backend change (ellipsis-dev/ellipsis#5421) that stamps every response with an X-Request-ID header and includes request_id in the 500 body.

Changes

  • ApiError gains a requestId field and appends (request id: ...) to its message when present. Commands that print err.message (e.g. ping) get this for free.
  • errorDetail becomes parseErrorResponse, returning { detail, requestId } from a single read of the response. The id is taken from the X-Request-ID header (set on every response) and falls back to the body's request_id (present on 500s).

Tests

  • parseErrorResponse: reads the id from the header, falls back to the body request_id, and still works for non-JSON bodies that carry the header.
  • ApiClient.request: a non-2xx surfaces requestId on the thrown ApiError and in its message.
  • Full suite green (107 tests); typecheck, build, and the Bun compile smoke check all pass.

ApiError now captures the request id the backend stamps on every response (the X-Request-ID header, with the 500 body's request_id as a fallback) and appends it to the error message, so a failed call hands the user something we can grep our logs for. errorDetail becomes parseErrorResponse, returning both the detail and the id from a single read of the response.
@hbrooks hbrooks merged commit fe247c2 into main Jun 30, 2026
1 check passed
@hbrooks hbrooks mentioned this pull request Jun 30, 2026
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