test(error-handler): cover the requestId field on 5xx responses (#338)#339
Merged
Merged
Conversation
#336 added `requestId` to the OpenAPI Error component schema as an optional field on every error response. The runtime side (`app/middleware/error-handler.js`) was already emitting it when the request reached the request-id middleware, but there was no behavioral test pinning the contract — a future refactor could silently stop emitting the field and the spec-shape assertion wouldn't catch the runtime divergence. Add two cases: - 5xx response carries requestId when req.id is set (stands up a minimal app where an id-tagging middleware fires before the handler, mirroring the production order from server.js). - 5xx response OMITS requestId when no id is available (catches a future regression that synthesizes an empty string or null instead of leaving the field off — operators rely on the field's presence to distinguish "no correlator" from "empty correlator"). Test count: 785 → 787. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Closes #338.
Summary
Adds two behavioral tests for the
requestIdfield that #336 declared in the OpenAPI Error schema:requestIdwhen req.id is set (verbatim).requestIdwhen no id is available (no synthetic empty/null).Test plan
npm run lint && npm test— 787 passing (was 785).Proudly Made in Nebraska. Go Big Red! 🌽 https://xkcd.com/2347/