Skip to content

Bump server/shared: request-id correlation + single-source 500 logging - #149

Merged
buzz-code merged 1 commit into
mainfrom
claude/dokploy-logs-management-rszzop
Aug 22, 2026
Merged

buzz-code merged 1 commit into
mainfrom
claude/dokploy-logs-management-rszzop

Conversation

@buzz-code

Copy link
Copy Markdown
Owner

What

Bumps server/shared to nra-server#40 (merged as 7176514).

Adds, all wired into bootstrapNraApplication/setupApplication which server/src/main.ts already calls — no app-side code changes needed:

  • requestIdMiddleware — reuses an incoming X-Request-Id header or generates a uuid, assigns it to req.id, echoes it back as the X-Request-Id response header.
  • AllExceptionsFilter — every 5xx (from a handler, guard, pipe, or middleware) gets its real error/stack attached before pino logs it. Replaces LoggerErrorInterceptor, which only covered handler-thrown exceptions.
  • customLogLevel / quietReqLogger in pino.config.ts — 5xx now logs at error level and 4xx at warn (previously everything logged at info, confirmed against a real production log line from student-report-nra); quietReqLogger: true adds a lightweight top-level reqId field.

Net effect: every log line for a request carries the same correlation id (req.id, or reqId with quietReqLogger), and every 500 logs once, at error level, with its full stack — see nra-server#40 for the full design writeup.

No CONSUMER_CHANGES.md row 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

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.
Copilot AI lite review requested due to automatic review settings August 22, 2026 20:54

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 requestIdMiddleware to reuse/generate request id, attach to req.id, echo via X-Request-Id header.
  • Add global AllExceptionsFilter to attach real exception to response.err for all 5xx so nestjs-pino logs real stack once.
  • Update pino config to log 5xx at error, 4xx at warn, enable quietReqLogger for top-level reqId.
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.

@buzz-code
buzz-code merged commit f1113eb into main Aug 22, 2026
5 checks passed
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.

3 participants