Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: OT Baggage is parsing incorrectly #5159

Open
jkalberer opened this issue Jan 28, 2025 · 1 comment
Open

[BUG]: OT Baggage is parsing incorrectly #5159

jkalberer opened this issue Jan 28, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@jkalberer
Copy link

jkalberer commented Jan 28, 2025

Tracer Version(s)

5.31.0

Node.js Version(s)

v18.18.1

Bug Report

It looks like when you're adding legacy open-trace baggage, you aren't re-encoding the values. This is causing our server to 500.

Our customer is sending us a request with a baggage header. This header is encoded but has a sentry-release value that when unencoded, contains a newline in the value.

When the ot-baggage-sentry-release header is being sent to DD, it's not encoded and causes Node to throw an error.

Reproduction Code

Send a request to a server that includes this header:

'baggage': 'sentry-trace_id=7f0832d6a7134559905a6928a7c308c2,sentry-environment=production,sentry-release=foo%402025.0122.110223%0A,sentry-public_key=4f5f8260da4b434c84e634b90323173d,sentry-transaction=/api/test/%7Bpk%7D/test2/%7Bfeature%7D'

Error Logs

TypeError [ERR_INVALID_CHAR]: Invalid character in header content ["ot-baggage-sentry-release"]
              at __node_internal_captureLargerStackTrace (node:internal/errors:496:5)
              at new NodeError (node:internal/errors:405:5)
              at __node_internal_ (node:_http_outgoing:628:11)
              at ClientRequest.setHeader (node:_http_outgoing:651:3)
              at new ClientRequest (node:_http_client:291:14)
              at Object.request (node:http:100:10)
              at /Users/jkalberer/Desktop/dev/project/node_modules/dd-trace/packages/datadog-instrumentations/src/http/client.js:72:31
              at run (/Users/jkalberer/Desktop/dev/project/node_modules/dc-polyfill/patch-channel-store-methods.js:39:16)
              at DatadogStorage.run (/Users/jkalberer/Desktop/dev/project/node_modules/dd-trace/packages/datadog-core/src/storage.js:41:22)
              at /Users/jkalberer/Desktop/dev/project/node_modules/dc-polyfill/patch-channel-store-methods.js:70:18
              at ch.runStores (/Users/jkalberer/Desktop/dev/project/node_modules/dc-polyfill/patch-channel-store-methods.js:48:14)
              at Object.request (/Users/jkalberer/Desktop/dev/project/node_modules/dd-trace/packages/datadog-instrumentations/src/http/client.js:50:27)
              at RedirectableRequest._performRequest (/Users/jkalberer/Desktop/dev/project/node_modules/follow-redirects/index.js:337:24)
              at new RedirectableRequest (/Users/jkalberer/Desktop/dev/project/node_modules/follow-redirects/index.js:111:8)
              at Object.request (/Users/jkalberer/Desktop/dev/project/node_modules/follow-redirects/index.js:543:14)
              at dispatchHttpRequest (/Users/jkalberer/Desktop/dev/project/node_modules/axios/lib/adapters/http.js:464:21)
              at <anonymous> (/Users/jkalberer/Desktop/dev/project/node_modules/axios/lib/adapters/http.js:152:5)
              at new Promise (<anonymous>)
              at wrapAsync (/Users/jkalberer/Desktop/dev/project/node_modules/axios/lib/adapters/http.js:132:10)
              at http (/Users/jkalberer/Desktop/dev/project/node_modules/axios/lib/adapters/http.js:170:10)
              at Axios.dispatchRequest (/Users/jkalberer/Desktop/dev/project/node_modules/axios/lib/core/dispatchRequest.js:51:10)

### Tracer Config

_No response_

### Operating System

_No response_

### Bundling

No Bundling
@jkalberer jkalberer added the bug Something isn't working label Jan 28, 2025
@jkalberer
Copy link
Author

A workaround to stop the crashing is to add legacyBaggageEnabled: false init options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant