Skip to content

test(error-handler): cover the requestId field on 5xx responses (#338)#339

Merged
CryptoJones merged 1 commit into
masterfrom
test/error-handler-requestid-emission
May 19, 2026
Merged

test(error-handler): cover the requestId field on 5xx responses (#338)#339
CryptoJones merged 1 commit into
masterfrom
test/error-handler-requestid-emission

Conversation

@CryptoJones
Copy link
Copy Markdown
Owner

Closes #338.

Summary

Adds two behavioral tests for the requestId field that #336 declared in the OpenAPI Error schema:

  • 5xx carries requestId when req.id is set (verbatim).
  • 5xx OMITS requestId when 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/

#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>
@CryptoJones CryptoJones merged commit 7f1e436 into master May 19, 2026
3 checks passed
@CryptoJones CryptoJones deleted the test/error-handler-requestid-emission branch May 19, 2026 18:48
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.

test(error-handler): no behavioral test for requestId emission on 5xx

1 participant