Skip to content

feat(gateway): generate and propagate X-Correlation-Id (GrantFox FWC26) - #1018

Merged
greatest0fallt1me merged 3 commits into
CalloraOrg:mainfrom
vally111:feat/x-correlation-id-gateway-fwc26
Jul 29, 2026
Merged

feat(gateway): generate and propagate X-Correlation-Id (GrantFox FWC26)#1018
greatest0fallt1me merged 3 commits into
CalloraOrg:mainfrom
vally111:feat/x-correlation-id-gateway-fwc26

Conversation

@vally111

Copy link
Copy Markdown
Contributor
  • Mount correlationMiddleware on the gateway router so every /api/gateway request resolves an X-Correlation-Id (from client header → req.id → UUID v4)
  • Forward x-correlation-id alongside x-request-id in all outbound upstream fetch calls so multi-hop request chains are fully traceable
  • Attach req.correlationId for downstream handlers and structured logging
  • Set X-Correlation-Id response header so callers can correlate request chains
  • Declare req.correlationId on Express.Request in express.d.ts
  • Add focused test suite in gatewayRoutes.test.ts covering:
    • Response header always present (including 401/402/429 short-circuits)
    • Client-supplied header echoed exactly
    • Fallback to X-Request-Id when no correlation header is provided
    • UUID generated when neither header is present
    • Outbound upstream headers carry x-correlation-id
    • Independent propagation of request-id and correlation-id
    • Oversized header sanitisation (>128 chars falls back to req.id)
    • Control-character stripping (header injection prevention)
    • Response/outbound consistency

Closes #897

- Mount correlationMiddleware on the gateway router so every /api/gateway
  request resolves an X-Correlation-Id (from client header → req.id → UUID v4)
- Forward x-correlation-id alongside x-request-id in all outbound upstream
  fetch calls so multi-hop request chains are fully traceable
- Attach req.correlationId for downstream handlers and structured logging
- Set X-Correlation-Id response header so callers can correlate request chains
- Declare req.correlationId on Express.Request in express.d.ts
- Add focused test suite in gatewayRoutes.test.ts covering:
  - Response header always present (including 401/402/429 short-circuits)
  - Client-supplied header echoed exactly
  - Fallback to X-Request-Id when no correlation header is provided
  - UUID generated when neither header is present
  - Outbound upstream headers carry x-correlation-id
  - Independent propagation of request-id and correlation-id
  - Oversized header sanitisation (>128 chars falls back to req.id)
  - Control-character stripping (header injection prevention)
  - Response/outbound consistency

Closes #FWC26
@drips-wave

drips-wave Bot commented Jul 28, 2026

Copy link
Copy Markdown

@vally111 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@greatest0fallt1me
greatest0fallt1me merged commit 93a277a into CalloraOrg:main Jul 29, 2026
1 check passed
@greatest0fallt1me

Copy link
Copy Markdown
Contributor

Merged into main via admin resolver (-X theirs).

@greatest0fallt1me

Copy link
Copy Markdown
Contributor

CI passed, solid PR — merged.

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.

Add correlation-id propagation on /api/gateway [b#032]

2 participants