Add parsing limits to tracestate and traceparent#5674
Conversation
|
Thank you for updating Change log entry section 👏 Visited at: 2026-05-05 21:15:41 UTC |
BenchmarksBenchmark execution time: 2026-05-06 21:44:52 Comparing candidate commit afff006 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 45 metrics, 1 unstable metrics.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e906c78244
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
p-datadog
left a comment
There was a problem hiding this comment.
nitpick (non-blocking): mention the OWS normalization in the changelog
Beyond the size limits, the rewrite changes trace_state to be whitespace-normalized: "v=1, v2=2 " extracts as "v=1,v2=2" because vendors.each(&:strip!) then vendors.join(',') reconstructs without OWS. More spec-compliant (W3C says OWS in tracestate is allowed but not significant), but it's customer-observable for any service inspecting digest.trace_state after extraction. The current changelog entry covers parsing limits — extending it to "Add parsing limits and normalize OWS in tracestate propagation headers" would catch this side effect.
Side note: String#strip removes \n, \v, \f, \r in addition to space and tab. The W3C OWS pattern is space and HTAB only. Not a security issue (those chars are malformed input anyway), but stricter than the spec calls for.
|
suggestion (non-blocking): short-circuit on invalid encoding before split At The byteslice+chop pattern fixes the codex-flagged truncation case, but invalid UTF-8 input under the byte limit still hits return unless tracestate
return unless tracestate.valid_encoding?
|
@p-datadog Added the whitespace changes to the changelog. Thank you! |
@p-datadog This came up on every step of these changes, and I chose not to address these immediately because they don't seem to be reported errors today, and a proper fix likely requires pervasive inspection of all the HTTP header code flow to know the best place to implement a UTF-8 validation/normalization. |
Typing analysisNote: Ignored files are excluded from the next sections. Untyped methodsThis PR introduces 3 partially typed methods, and clears 3 partially typed methods. Partially typed methods (+3-3)❌ Introduced:If you believe a method or an attribute is rightfully untyped or partially typed, you can add |
🎉 All green!❄️ No new flaky tests detected 🎯 Code Coverage (details) 🔗 Commit SHA: afff006 | Docs | Datadog PR Page | Give us feedback! |
What does this PR do?
Ensure when parsing the W3C Trace Context propagation headers
traceparentandtracestate, ensure they respect our processing limits:traceparent: 512 bytestracestate: 512 bytestracestatemembers: 32 entriesChange log entry
Yes. Add parsing limits to
tracestateandtraceparentpropagation headers and remove whitespace around list members.How to test the change?
bundle exec rspec spec/datadog/tracing/distributed/trace_context_spec.rb