Repository navigation
Conversation
The resource spec was updated to require decoding OTEL_RESOURCE_ATTRIBUTES values per the W3C Baggage value grammar, but OTELResourceDetector::Detect() stored the raw substring after '=' verbatim. A value like "key=hello%20world" therefore became the literal string "hello%20world" instead of "hello world". Adds a local percent-decode helper scoped to resource_detector.cc; a malformed escape sequence is left in the value as-is rather than dropping the attribute, consistent with this parser never validating attribute syntax elsewhere. Fixes open-telemetry#1536
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4364 +/- ##
==========================================
+ Coverage 81.77% 81.78% +0.01%
==========================================
Files 493 493
Lines 19456 19474 +18
==========================================
+ Hits 15909 15924 +15
- Misses 3547 3550 +3
🚀 New features to boost your workflow:
|
Per marcalff's review comment, avoids re-evaluating and re-casting the same byte twice when checking and decoding a percent-escape.
# Conflicts: # CHANGELOG.md
|
@marcalff addressed the twice-happening cast; please check once. |
…e Unavailable resolving actions)
|
Please do not push new commit to re trigger a failed build. Also, no need to merge from main every time main changes. |
@marcalff Understood. I was just trying to make sure that the PR remains in a mergeable state; I will avoid repeated merges moving forward. |
|
Now that #4376 got in, it's your turn. |
Summary
Fixes #1536.
The OpenTelemetry resource specification now requires values from
OTEL_RESOURCE_ATTRIBUTESto be decoded using the W3C Baggage value grammar. While looking into this, I noticed thatOTELResourceDetector::Detect()was parsing the attributes but storing values exactly as they appeared in the environment.For example:
was producing the value
hello%20worldinstead ofhello world.This PR adds a small percent-decoding helper in
sdk/src/resource/resource_detector.ccand applies it when parsing attribute values.Malformed escape sequences are preserved rather than causing the attribute to be rejected, which matches the existing parser behavior of being permissive instead of validating attribute syntax.
The change is intentionally scoped to value decoding only. Parsing, trimming, and attribute key handling remain unchanged.
Testing
Added tests covering:
%20,%2C,%25).%or invalid hex digits).OTELResourceDetectorbehavior to ensure there are no regressions.The full
resource_testsuite passes locally.