feat(error-handler): include requestId in every error response#1136
Open
semantabhandari wants to merge 1 commit into
Open
feat(error-handler): include requestId in every error response#1136semantabhandari wants to merge 1 commit into
semantabhandari wants to merge 1 commit into
Conversation
Add fastify's request.id to the ErrorResponse envelope in all three branches (HttpError, domain-mapped, unhandled fallback) and to the registered ErrorResponse JSON schema. A client-reported failure can now be correlated with its request-scoped log entries by quoting the id from the response body; when requestIdHeader is configured the id the load balancer supplied is echoed back.
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.
Every error response now carries
requestId(fastify'srequest.id) alongside the existing fields. When the app configuresrequestIdHeader(e.g. a load balancer'sx-request-id), that same id is echoed back, so a client-reported failure can be correlated directly with its request-scoped log entries instead of searching by message and timestamp.Additive change: new field on the
ErrorResponsetype, the registeredErrorResponseJSON schema, and all three handler branches (HttpError, domain-mapped, unhandled 500). No behavioural change to status codes or logging. NewrequestId.test.tscovers all three lanes plus header-supplied ids; README/FEATURES updated. 55/55 tests, typecheck and lint clean.