Fix baggage header escaping of non-ASCII values - #12564
gh-worker-dd-mergequeue-cf854d[bot] merged 3 commits into
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
More details
The shared encoding check now stops the scan at each unsafe ASCII or non-ASCII character. All later characters stay in the percent-encoding path.
🤖 Datadog Autotest · Commit 173a447 · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest
🟢 Java Benchmark SLOs — All performance SLOs passed
PR vs. master results
Commit: Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion. |
jordan-wong
left a comment
There was a problem hiding this comment.
Approved from IDM perspective but we do not really touch this area of the codebase - would like to see some review from Capabilities, tagging @mhlidd as the current sole file contributor
mhlidd
left a comment
There was a problem hiding this comment.
Some additional fixes that are relevant to the issue.
Co-authored-by: mhlidd <matthew.li@datadoghq.com>
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
URL-decoded values and keys can still round-trip incorrectly for + and %.
Review effort: Lite
Findings: None
What changed in this PR
Fixes baggage header percent escaping for non-ASCII characters.
Changes:
- Corrects escape scanning logic.
- Adds Unicode, control-character, and key/value regression tests.
| File | Summary |
|---|---|
dd-trace-core/src/main/java/datadog/trace/core/util/PercentEscaper.java |
Updates escaping logic; moderate issues remain for + in values and % in keys. |
dd-trace-core/src/test/java/datadog/trace/core/util/PercentEscaperTest.java |
Adds comprehensive escaping regression coverage; round-trip tests for the remaining issues are requested. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
/merge |
|
View all feedbacks in Devflow UI.
The expected merge time in
|
What Does This Do
Fixes
PercentEscaper.nextEscapeIndex()skipping non-ASCII characters, so baggage keys and values are now fully percent-escaped.Motivation
See Jira
APMS-20590nextEscapeIndex()duplicated part ofneedsEncoding()but tested only the unsafe-octet table, dropping thec > '~'andc <= ' 'conditions. Those tables are 93 entries (values) / 126 (keys), so every non-ASCII character sits outside them and the scan skipped straight past it.The first character was still escaped via the
escape(String, boolean[])fast path, so the bug only showed from the second escape onward — raw UTF-8 bytes went into the header value and were mangled in transit.Testing
PercentEscaperTest— 12 tests covering the 2-byte, 3-byte and 4-byte (surrogate pair) UTF-8 branches, non-ASCII at the start vs. after an escape, repeated interleaving, and both the key and value octet tables. All pass; 10 fail with the fix reverted.1.66.0emits the mangled header above, a local build of this branch emits the fully escaped one.Additional Notes
Contributor Checklist
./gradlew spotlessApply🤖 Generated with Claude Code
Jira ticket: [PROJ-IDENT]