Repository navigation
Bump server/shared: request-id correlation + single-source 500 logging - #149
Merged
Merged
Conversation
Picks up nra-server#40: requestIdMiddleware (X-Request-Id echoed on every response, correlates all logs for a request via req.id/reqId), AllExceptionsFilter (every 5xx logs with its real stack regardless of where it was thrown, replacing LoggerErrorInterceptor), and pino customLogLevel/quietReqLogger fixes (500s were logging at info level, not error). No app-side changes needed - fully additive, wired into bootstrapNraApplication already used by main.ts.
There was a problem hiding this comment.
🟡 Changes recommended
requestIdMiddleware currently treats req.headers['x-request-id'] as string (can be string[]) and assigns req.id without typing, risking invalid header echo/log correlation and TS type errors.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Update server/shared (nra-server submodule) to pick up cross-cutting request correlation + improved 5xx logging behavior used by server/src/main.ts via bootstrapNraApplication.
Changes:
- Add
requestIdMiddlewareto reuse/generate request id, attach toreq.id, echo viaX-Request-Idheader. - Add global
AllExceptionsFilterto attach real exception toresponse.errfor all 5xx sonestjs-pinologs real stack once. - Update pino config to log 5xx at
error, 4xx atwarn, enablequietReqLoggerfor top-levelreqId.
File summaries
| File | Description |
|---|---|
server/shared (submodule) |
Bump shared NestJS utilities/logging for request-id correlation + unified 5xx logging behavior |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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
Bumps
server/sharedto nra-server#40 (merged as7176514).Adds, all wired into
bootstrapNraApplication/setupApplicationwhichserver/src/main.tsalready calls — no app-side code changes needed:requestIdMiddleware— reuses an incomingX-Request-Idheader or generates a uuid, assigns it toreq.id, echoes it back as theX-Request-Idresponse header.AllExceptionsFilter— every 5xx (from a handler, guard, pipe, or middleware) gets its real error/stack attached before pino logs it. ReplacesLoggerErrorInterceptor, which only covered handler-thrown exceptions.customLogLevel/quietReqLoggerinpino.config.ts— 5xx now logs aterrorlevel and 4xx atwarn(previously everything logged atinfo, confirmed against a real production log line fromstudent-report-nra);quietReqLogger: trueadds a lightweight top-levelreqIdfield.Net effect: every log line for a request carries the same correlation id (
req.id, orreqIdwithquietReqLogger), and every 500 logs once, aterrorlevel, with its full stack — see nra-server#40 for the full design writeup.No
CONSUMER_CHANGES.mdrow on the nra-server side — purely additive.Testing
cd server && yarn test— 990/990 passing, against the real bumped submodule (not a copy).Generated by Claude Code