Skip to content

feat(api): BA-115 echo or generate request correlation IDs on error responses - #1043

Open
ranjeetprabhatedu-dotcom wants to merge 1 commit into
BlockDash-Studios:mainfrom
ranjeetprabhatedu-dotcom:feat/correlation-ids-1028
Open

ranjeetprabhatedu-dotcom wants to merge 1 commit into
BlockDash-Studios:mainfrom
ranjeetprabhatedu-dotcom:feat/correlation-ids-1028

Conversation

@ranjeetprabhatedu-dotcom

Copy link
Copy Markdown

Summary

This PR implements BA-115 to ensure all API error responses echo or generate a request correlation ID for consistent tracing and observability.

  • Implements getOrGenerateCorrelationId to inspect incoming headers (x-correlation-id, x-request-id) or generate a secure UUID.
  • Adds CorrelationIdExceptionFilter in app.controller.ts and binds it globally via app.useGlobalFilters(...) in main.ts.
  • Attaches x-correlation-id to response headers and embeds correlationId, statusCode, message, and timestamp into error payloads.
  • Adds comprehensive unit tests in app.controller.spec.ts testing header extraction, UUID generation fallback, and filter payload formatting across client and server exceptions.
  • Scoped strictly to the 3 allowlisted files:
    • BackendAcademy/src/main.ts
    • BackendAcademy/src/app.controller.ts
    • BackendAcademy/src/app.controller.spec.ts

Closes #1028

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.

BA-115 — Add request correlation IDs to error responses

1 participant