Skip to content

Propagate correlation IDs across API requests#113

Merged
Abd-Standard merged 2 commits into
Core-Foundry:mainfrom
michaelvic123:feat/correlation-id-propagation
Jun 20, 2026
Merged

Propagate correlation IDs across API requests#113
Abd-Standard merged 2 commits into
Core-Foundry:mainfrom
michaelvic123:feat/correlation-id-propagation

Conversation

@michaelvic123

@michaelvic123 michaelvic123 commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

closes #95

What

Every API request now carries a correlation ID that is logged server-side and echoed back to the caller, making it easy to trace a request end-to-end across logs.

Changes

utils/request-id.ts

  • Added resolveCorrelationId(header) — honours an incoming X-Correlation-Id header if present, otherwise generates a fresh UUID

api/events-server.ts

  • Resolves correlation ID from X-Correlation-Id request header on every request
  • Sets X-Correlation-Id on every response (including 4xx/5xx)
  • Added X-Correlation-Id to Access-Control-Allow-Headers so browser clients can send it
  • Threads correlationId into every logger call alongside the existing requestId

tests/events-server.test.ts (new)

  • Generates a correlation ID when none is provided
  • Echoes back the caller-supplied ID unchanged
  • Both x-request-id and x-correlation-id present and distinct
  • Correlation ID flows through on 404 responses

Backward compatibility

No existing behaviour changes — X-Request-Id is still set, all endpoints work identically. Callers that don't send X-Correlation-Id get one generated for them.

- add resolveCorrelationId() — honours incoming X-Correlation-Id header,
  falls back to a new UUID when absent
- echo X-Correlation-Id back on every response
- expose X-Correlation-Id in Access-Control-Allow-Headers for CORS
- include correlationId in every logger call alongside requestId
- add events-server tests covering generation, echo, and 404 flow
@Abd-Standard

Copy link
Copy Markdown
Collaborator

please resolve conflicts

…routes

Resolved conflict in events-server.ts: layered correlation ID
propagation (resolveCorrelationId, X-Correlation-Id header) onto
the upstream's refactored flat-routing structure which added
webhook signature verification and user preference endpoints.
@michaelvic123 michaelvic123 force-pushed the feat/correlation-id-propagation branch from 8109be3 to 3ce6c2f Compare June 20, 2026 12:16
@Abd-Standard Abd-Standard merged commit 91b1c48 into Core-Foundry:main Jun 20, 2026
1 of 2 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.

[Backend] Introduce Request Correlation IDs

2 participants