Skip to content

fix(resource): percent-decode attribute values#3586

Open
9999years wants to merge 1 commit into
open-telemetry:mainfrom
9999years:wiggles/ynrl
Open

fix(resource): percent-decode attribute values#3586
9999years wants to merge 1 commit into
open-telemetry:mainfrom
9999years:wiggles/ynrl

Conversation

@9999years

Copy link
Copy Markdown
Contributor

Fixes #857

Changes

$OTEL_RESOURCE_ATTRIBUTES values are now percent-decoded in line with the spec.

Merge requirement checklist

  • CONTRIBUTING guidelines followed
  • Unit tests added/updated (if applicable)
  • Appropriate CHANGELOG.md files updated for non-trivial, user-facing changes
  • Changes in public API reviewed (if applicable)

@9999years 9999years changed the title resource: percent-decode attribute values fix(resource): percent-decode attribute values Jul 7, 2026
@codecov

codecov Bot commented Jul 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.2%. Comparing base (10dde18) to head (232b3c0).
⚠️ Report is 9 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##            main   #3586     +/-   ##
=======================================
+ Coverage   83.0%   83.2%   +0.1%     
=======================================
  Files        130     130             
  Lines      27993   28234    +241     
=======================================
+ Hits       23250   23493    +243     
+ Misses      4743    4741      -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@9999years
9999years marked this pull request as ready for review July 7, 2026 17:43
@9999years
9999years requested a review from a team as a code owner July 7, 2026 17:43
9999years added a commit to MercuryTechnologies/buck2 that referenced this pull request Jul 7, 2026
This integrates the Mercury `opentelemetry-rust` fork with fixes from a
couple PRs:

See:
- open-telemetry/opentelemetry-rust#3586
- open-telemetry/opentelemetry-rust#3587

Follow-up to Arian's review: #18 (review)
9999years added a commit to MercuryTechnologies/buck2 that referenced this pull request Jul 7, 2026
This integrates the Mercury `opentelemetry-rust` fork with fixes from a
couple PRs:

See:
- open-telemetry/opentelemetry-rust#3586
- open-telemetry/opentelemetry-rust#3587

Follow-up to Arian's review: #18 (review)
9999years added a commit to MercuryTechnologies/buck2 that referenced this pull request Jul 8, 2026
This integrates the Mercury `opentelemetry-rust` fork with fixes from a
couple PRs:

See:
- open-telemetry/opentelemetry-rust#3586
- open-telemetry/opentelemetry-rust#3587

Follow-up to Arian's review: #18 (review)
hdgarrood pushed a commit to MercuryTechnologies/buck2 that referenced this pull request Jul 10, 2026
This integrates the Mercury `opentelemetry-rust` fork with fixes from a
couple PRs:

See:
- open-telemetry/opentelemetry-rust#3586
- open-telemetry/opentelemetry-rust#3587

Follow-up to Arian's review: #18 (review)
hdgarrood pushed a commit to MercuryTechnologies/buck2 that referenced this pull request Jul 11, 2026
This integrates the Mercury `opentelemetry-rust` fork with fixes from a
couple PRs:

See:
- open-telemetry/opentelemetry-rust#3586
- open-telemetry/opentelemetry-rust#3587

Follow-up to Arian's review: #18 (review)
hdgarrood pushed a commit to MercuryTechnologies/buck2 that referenced this pull request Jul 11, 2026
This integrates the Mercury `opentelemetry-rust` fork with fixes from a
couple PRs:

See:
- open-telemetry/opentelemetry-rust#3586
- open-telemetry/opentelemetry-rust#3587

Follow-up to Arian's review: #18 (review)
hdgarrood pushed a commit to MercuryTechnologies/buck2 that referenced this pull request Jul 15, 2026
This integrates the Mercury `opentelemetry-rust` fork with fixes from a
couple PRs:

See:
- open-telemetry/opentelemetry-rust#3586
- open-telemetry/opentelemetry-rust#3587

Follow-up to Arian's review: #18 (review)
hdgarrood pushed a commit to MercuryTechnologies/buck2 that referenced this pull request Jul 15, 2026
This integrates the Mercury `opentelemetry-rust` fork with fixes from a
couple PRs:

See:
- open-telemetry/opentelemetry-rust#3586
- open-telemetry/opentelemetry-rust#3587

Follow-up to Arian's review: #18 (review)
hdgarrood pushed a commit to MercuryTechnologies/buck2 that referenced this pull request Jul 15, 2026
This integrates the Mercury `opentelemetry-rust` fork with fixes from a
couple PRs:

See:
- open-telemetry/opentelemetry-rust#3586
- open-telemetry/opentelemetry-rust#3587

Follow-up to Arian's review: #18 (review)
@@ -50,9 +51,13 @@ fn construct_otel_resources(s: String) -> Resource {
None => return None,
};
let key = parts.0.trim();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we should also percent-decode keys. As per specs:

The OTEL_RESOURCE_ATTRIBUTES environment variable will contain of a list of key value pairs, represented as key1=value1,key2=value2. All attribute values MUST be considered strings. The , and = characters in keys and values MUST be percent encoded. Other characters MAY be [percent-encoded](https://datatracker.ietf.org/doc/html/rfc3986#section-2.1), e.g. values outside the ANSI characters set.

// (e.g. `%20`) in the value is preserved. Per the Resource SDK spec
// the value MUST be percent-decoded; keys are baggage tokens and are
// not encoded.
let value = percent_decode_str(parts.1.trim()).decode_utf8_lossy();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

decode_utf8_lossy() accepts invalid encoded UTF-8 by inserting replacement characters. The Resource SDK spec says decoding failures should discard the entire env var and report an error. The existing baggage propagator already uses decode_utf8() and logs invalid UTF-8 instead of doing lossy decoding, so this new path should probably follow that shape.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Decode values from OTEL_RESOURCE_ATTRIBUTES

2 participants