Show the server request id on non-2xx responses#17
Merged
Conversation
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.
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
When an API call fails,
agentnow 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:
After:
Pairs with the backend change (ellipsis-dev/ellipsis#5421) that stamps every response with an
X-Request-IDheader and includesrequest_idin the 500 body.Changes
ApiErrorgains arequestIdfield and appends(request id: ...)to its message when present. Commands that printerr.message(e.g.ping) get this for free.errorDetailbecomesparseErrorResponse, returning{ detail, requestId }from a single read of the response. The id is taken from theX-Request-IDheader (set on every response) and falls back to the body'srequest_id(present on 500s).Tests
parseErrorResponse: reads the id from the header, falls back to the bodyrequest_id, and still works for non-JSON bodies that carry the header.ApiClient.request: a non-2xx surfacesrequestIdon the thrownApiErrorand in its message.