Skip to content

fix(configuration): percent-decode keys and values in resource.attributes_list#6787

Merged
pichlermarc merged 3 commits into
open-telemetry:mainfrom
honeycombio:mike/percent-decode-attributes-list
Jun 15, 2026
Merged

fix(configuration): percent-decode keys and values in resource.attributes_list#6787
pichlermarc merged 3 commits into
open-telemetry:mainfrom
honeycombio:mike/percent-decode-attributes-list

Conversation

@MikeGoldsmith

Copy link
Copy Markdown
Member

Which problem is this PR solving?

The OTel resource spec says that , and = in OTEL_RESOURCE_ATTRIBUTES keys and values MUST be percent-encoded, and other characters MAY be percent-encoded. The configuration schema for resource.attributes_list uses the same format. The current parsing in mergeAttributesList ignores percent-encoding.

Spec: https://opentelemetry.io/docs/specs/otel/resource/sdk/#specifying-resource-information-via-an-environment-variable

Short description of the changes

Update mergeAttributesList in FileConfigFactory:

  • Split each entry by = and require exactly two parts (an unencoded = in a value means the entry is invalid per spec)
  • Percent-decode key and value with decodeURIComponent
  • On any parse or decode error, discard the entire attributes_list and emit a diag.warn (matches the spec's "on error, discard all" rule, and matches the existing EnvDetector in the opentelemetry-resources package)

Adds three fixtures + tests:

  • valid percent-encoded (%2C, %3D, %C3%A9)
  • invalid percent-sequence (%ZZ)
  • unencoded = in value

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  • 85 configuration package tests pass (3 new)
  • Full lint passes

Closes #6769

Per the OTel resource spec, `,` and `=` in attributes_list keys and
values MUST be percent-encoded, and other characters MAY be. Update
mergeAttributesList in FileConfigFactory to percent-decode each
key/value, and discard the entire attributes_list with a warning on
any parse or decode error (matches the EnvDetector in the resources
package and the spec's "on error, discard all" rule).

Adds three fixtures and tests: valid percent-encoding, invalid
percent-sequence (%ZZ), and unencoded `=` in value.

Closes open-telemetry#6769

Assisted-by: Claude Opus 4.6
@MikeGoldsmith
MikeGoldsmith requested a review from a team as a code owner June 5, 2026 13:11
Assisted-by: Claude Opus 4.6
@codecov

codecov Bot commented Jun 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.94%. Comparing base (55606c3) to head (ecf8baf).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...al/packages/configuration/src/FileConfigFactory.ts 90.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6787      +/-   ##
==========================================
- Coverage   94.96%   94.94%   -0.02%     
==========================================
  Files         380      380              
  Lines       12897    12910      +13     
  Branches     2937     2939       +2     
==========================================
+ Hits        12247    12258      +11     
- Misses        650      652       +2     
Files with missing lines Coverage Δ
...al/packages/configuration/src/FileConfigFactory.ts 96.72% <90.00%> (-1.45%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pichlermarc
pichlermarc added this pull request to the merge queue Jun 12, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Jun 12, 2026
@pichlermarc
pichlermarc added this pull request to the merge queue Jun 15, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Jun 15, 2026
@pichlermarc
pichlermarc added this pull request to the merge queue Jun 15, 2026
Merged via the queue into open-telemetry:main with commit b32bf39 Jun 15, 2026
31 checks passed
@MikeGoldsmith
MikeGoldsmith deleted the mike/percent-decode-attributes-list branch June 15, 2026 13:42
trentm added a commit to trentm/opentelemetry-js that referenced this pull request Jun 15, 2026
@otelbot-js otelbot-js Bot mentioned this pull request Jul 2, 2026
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.

[configuration] parsing of config.resource.attributes_list should handle percent-encoding

3 participants