Skip to content

feat(api): add X-Reflex-Request-ID header middleware#220

Open
huynna12 wants to merge 1 commit into
FastCrest:mainfrom
huynna12:feat/request-id-header
Open

feat(api): add X-Reflex-Request-ID header middleware#220
huynna12 wants to merge 1 commit into
FastCrest:mainfrom
huynna12:feat/request-id-header

Conversation

@huynna12

@huynna12 huynna12 commented Jun 8, 2026

Copy link
Copy Markdown

Description

Adds an HTTP middleware that generates a UUID4 per request and attaches it as X-Reflex-Request-ID on all HTTP responses. The same ID is recorded on the OTel act span as tether.request_id for fleet-scale log tracing.

Closes #93

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Infrastructure / CI update

How Has This Been Tested?

  • pytest tests/ passes locally
  • tether doctor sanity check
  • Other (please specify):

Description:

Added 5 unit tests in tests/test_request_id_header.py covering:

  • Header present on /health and /act responses
  • Header value is a valid UUID4
  • Each request gets a unique ID
  • Context variable holds the correct ID inside the route handler

Run with: pytest tests/test_request_id_header.py -v

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have kept the PR scoped to a single concern (one concern per PR)

@huynna12 huynna12 requested a review from rylinjames as a code owner June 8, 2026 23:25
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.

[API] Add X-Reflex-Request-ID Header to All Responses

1 participant