Skip to content

fix: ensure tracing headers forwarded on all server-side API requests#802

Open
thostetler wants to merge 7 commits intoadsabs:masterfrom
thostetler:fix/ensure-trace-ids
Open

fix: ensure tracing headers forwarded on all server-side API requests#802
thostetler wants to merge 7 commits intoadsabs:masterfrom
thostetler:fix/ensure-trace-ids

Conversation

@thostetler
Copy link
Member

Server-side API requests were silently dropping distributed tracing
headers (X-Original-Uri, X-Original-Forwarded-For, X-Forwarded-For,
X-Amzn-Trace-Id). The root cause: Ramda's pick() does exact key
matching, but Node.js IncomingMessage.headers lowercases all keys
while TRACING_HEADERS uses mixed case -- so pick() always returned {}.

  • Added pickTracingHeaders utility for case-insensitive extraction from Node.js IncomingHttpHeaders
  • Added pickTracingHeadersEdge utility for Edge Runtime Headers, refactored initSession.ts to use it
  • Fixed absCanonicalization.ts search fetch (the originally reported gap)
  • Fixed serverside bootstrap.ts to forward tracing headers
  • Replaced broken pick(TRACING_HEADERS, ...) in fetchSearchSSR and resolveObjectQuerySSR
  • Added tracing headers to verifyMiddleware and middleware link_gateway analytics fetch

@codecov
Copy link

codecov bot commented Feb 13, 2026

Codecov Report

❌ Patch coverage is 97.10145% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 61.6%. Comparing base (968d8a6) to head (9a1e8d6).

Files with missing lines Patch % Lines
src/api/objects/objects.ts 50.0% 1 Missing ⚠️
src/api/search/search.ts 66.7% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           master    #802     +/-   ##
========================================
+ Coverage    61.6%   61.6%   +0.1%     
========================================
  Files         312     314      +2     
  Lines       36000   36090     +90     
  Branches     1594    1603      +9     
========================================
+ Hits        22148   22225     +77     
- Misses      13815   13828     +13     
  Partials       37      37             
Files with missing lines Coverage Δ
src/config.ts 100.0% <100.0%> (ø)
src/lib/serverside/absCanonicalization.ts 64.1% <100.0%> (+1.0%) ⬆️
src/lib/serverside/bootstrap.ts 76.1% <100.0%> (ø)
src/middleware.ts 91.9% <100.0%> (+0.1%) ⬆️
src/middlewares/initSession.ts 91.2% <100.0%> (-0.2%) ⬇️
src/middlewares/verifyMiddleware.ts 92.2% <100.0%> (+0.4%) ⬆️
src/utils/tracing.edge.ts 100.0% <100.0%> (ø)
src/api/objects/objects.ts 31.2% <50.0%> (-0.5%) ⬇️
src/api/search/search.ts 45.2% <66.7%> (ø)

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

…action

Ramda's pick() is a no-op for tracing headers because Node.js
IncomingMessage lowercases all keys while TRACING_HEADERS uses
mixed case. This utility matches case-insensitively and restores
canonical casing for downstream services.
The bootstrap function used by absCanonicalization was not forwarding
tracing headers (X-Amzn-Trace-Id, X-Forwarded-For, etc.) to the
/accounts/bootstrap API endpoint. Extract headers from the incoming
request using pickTracingHeaders and append them to the outgoing fetch.
@thostetler thostetler marked this pull request as ready for review February 13, 2026 13:18
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.

1 participant