Add safe extraction for malformed base64 kafka headers#11472
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1435039fe3
ℹ️ 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".
1435039 to
e90e93e
Compare
This comment has been minimized.
This comment has been minimized.
🟢 Java Benchmark SLOs — All performance SLOs passed
PR vs. master resultsStartup Time
Commit: Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion. |
Kafka / producer-benchmarkParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 3 metrics, 0 unstable metrics. See unchanged results
|
Kafka / consumer-benchmarkParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 3 metrics, 0 unstable metrics. See unchanged results
|
What does this do
When
DD_KAFKA_CLIENT_BASE64_DECODING_ENABLED=true, the Kafka producer instrumentation callsextractContextAndGetSpanContexton the outgoingProducerRecordheaders. If any header value is not valid Base64 (e.g. a header produced by a non-DD service, a URL-safe encoded value, or a plain string),Base64.getDecoder().decode()throwsIllegalArgumentException. That exception escapes@OnMethodEnter, ByteBuddy'ssuppress = Throwable.classsilently swallows it and returns a nullAgentScope, which then causes an NPE inBaseDecorator.beforeFinishatscope.context()The fix moves the Base64 decode into a safe
Function<byte[], String>(Functions.base64Decode) that catches anyExceptionand returnsnull.TextMapExtractAdapter.forEachKeychecks fornull, logs the failing header key withEXCLUDE_TELEMETRY(since it's not actionable) , and skips that header. Valid headers continue to be processed normally.Depends to #11466
Motivation
Additional Notes
Contributor Checklist
type:and (comp:orinst:) labels in addition to any other useful labelsclose,fix, or any linking keywords when referencing an issueUse
solvesinstead, and assign the PR milestone to the issue/merge. You can also:/merge --commit-message "..."/merge -c/merge -f --reason "reason"; please use this judiciously, as some checks do not run at the PR-levelJira ticket: [PROJ-IDENT]