claude-code - ✅(Solved) Fix [BUG] OTEL_RESOURCE_ATTRIBUTES with raw non-ASCII (Korean) values silently drops all telemetry — bundled @opentelemetry/resources is outdated [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#55949Fetched 2026-05-05 06:02:08
View on GitHub
Comments
0
Participants
1
Timeline
3
Reactions
0
Author
Participants
Timeline (top)
labeled ×3

Error Message

There is no warning, error message, or stderr output. The only visible symptom is missing data on the collector side.

Error Messages/Logs

Root Cause

Root cause confirmed: the version of @opentelemetry/resources bundled into claude-code 2.1.116 is the old "strict" line (≤ v2.5.1), which performs W3C Baggage octet validation and rejects any character outside 0x210x7E. This was removed in open-telemetry/opentelemetry-js#6261, released in @opentelemetry/resources v2.6.0 (2026-03-03). claude-code's package.json declares "@opentelemetry/resources": "^2.0.0", but the lockfile/bundle is pinned to a pre-fix version.

Fix Action

Fix / Workaround

Root cause confirmed: the version of @opentelemetry/resources bundled into claude-code 2.1.116 is the old "strict" line (≤ v2.5.1), which performs W3C Baggage octet validation and rejects any character outside 0x210x7E. This was removed in open-telemetry/opentelemetry-js#6261, released in @opentelemetry/resources v2.6.0 (2026-03-03). claude-code's package.json declares "@opentelemetry/resources": "^2.0.0", but the lockfile/bundle is pinned to a pre-fix version.

Secondary asks:

  • Document the percent-encoding requirement for OTEL_RESOURCE_ATTRIBUTES (until the bump ships, this is the only workaround).

  • Even after the bump, parsing errors are still logged at diag.debug (invisible at default log level) — this is an upstream concern but worth surfacing as a warning at the claude-code layer for env-var misconfigurations.

  • open-telemetry/opentelemetry-js#6261 — removes the strict W3C Baggage octet validation (merged 2026-02-20, released in v2.6.0 on 2026-03-03).

  • open-telemetry/opentelemetry-specification#4847 — JS was identified as the only SIG performing fail-fast + un-encoded char checks. The strictness was JS-specific, not spec-mandated; spec is being clarified.

PR fix notes

PR #6261: fix(opentelemetry-resources): Update the Env Var Parsing Logic to Match Spec

Description (problem / solution / changelog)

<!-- We appreciate your contribution to the OpenTelemetry project! 👋🎉 Before creating a pull request, please make sure: - Your PR is solving one problem - Please provide enough information so that others can review your pull request - You have read the guide for contributing - See https://github.com/open-telemetry/opentelemetry-js/blob/main/CONTRIBUTING.md - You signed all your commits (otherwise we won't be able to merge the PR) - See https://github.com/open-telemetry/community/blob/main/guides/contributor#sign-the-cla - You added unit tests for the new functionality - You mention in the PR description which issue it is addressing, e.g. "Fixes #xxx". This will auto-close the issue that your PR fixes (if such) -->

Which problem is this PR solving?

This pull request updates the parsing logic for the OTEL_RESOURCE_ATTRIBUTES environment variable in the OpenTelemetry JS resources package to match recent specification changes. The main change is stricter handling: any parsing error now causes the entire environment variable to be discarded. The implementation and test suite have been updated to reflect these rules, while retaining backward compatibility for certain legacy behaviors.

Resource attribute parsing and validation:

  • Updated EnvDetector to discard the entire OTEL_RESOURCE_ATTRIBUTES value on any parsing error, as required by the spec. This includes errors such as invalid percent-encoding, missing key/value separators, or values exceeding 255 characters. [1] [2]
  • Removed W3C Baggage octet validation and related ASCII checks, since the spec no longer references these requirements. [1] [2] [3]
  • Retained backward compatibility: values are still stripped of leading/trailing quotes and limited to 255 characters, as before. [1] [2]

Test suite improvements:

  • Expanded tests in EnvDetector.test.ts to cover new spec-compliant behaviors, including error cases (invalid percent-encoding, unencoded = in values, missing separators), edge cases (spaces in keys/values, percent-encoded delimiters), and backward compatibility for quoted values. [1] [2] [3] [4] [5]

Logging and error handling:

  • Improved debug logging to handle both Error objects and plain strings when reporting parsing failures.

Documentation:

  • Updated the changelog to document the breaking change and specification alignment.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Added unit tests to ensure the behavior of the new env var parsing logic.

Checklist:

  • Followed the style guidelines of this project
  • Unit tests have been added
  • Documentation has been updated

Changed files

  • CHANGELOG.md (modified, +5/-0)
  • experimental/packages/opentelemetry-sdk-node/test/sdk.test.ts (modified, +5/-13)
  • packages/opentelemetry-resources/src/detectors/EnvDetector.ts (modified, +50/-61)
  • packages/opentelemetry-resources/test/detectors/node/EnvDetector.test.ts (modified, +171/-4)

Code Example

(none — failure is silent at default log level; SDK uses diag.debug which is suppressed)

---

export CLAUDE_CODE_ENABLE_TELEMETRY=1
   export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318
   export OTEL_RESOURCE_ATTRIBUTES="team=한글팀,case=raw"
   claude --print "hello"

---

export OTEL_RESOURCE_ATTRIBUTES="team=%ED%95%9C%EA%B8%80%ED%8C%80,case=pct"
   claude --print "hello"

---

$ strings /opt/homebrew/Caskroom/claude-code/2.1.116/claude | grep -oE '_isBaggageOctet[^,;)]{0,200}' | head
_isBaggageOctetString(H
_isBaggageOctetString(H

---

python3 -c "import urllib.parse; print(urllib.parse.quote('한글팀'))"
# %ED%95%9C%EA%B8%80%ED%8C%80

---

{
  "env": {
    "OTEL_RESOURCE_ATTRIBUTES": "team=%ED%95%9C%EA%B8%80%ED%8C%80,env=prod"
  }
}

---

2.1.116 (Claude Code)
RAW_BUFFERClick to expand / collapse

Issue draft for anthropics/claude-code

Title: [BUG] OTEL_RESOURCE_ATTRIBUTES with raw non-ASCII (Korean) values silently drops all telemetry — bundled @opentelemetry/resources is outdated

Labels: bug (auto)


Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report
  • I am using the latest version of Claude Code

What's Wrong?

When OTEL_RESOURCE_ATTRIBUTES contains a raw (un-percent-encoded) non-ASCII value such as Korean, no telemetry records reach the OTLP collector for that run — not just the offending attribute. The collector receives zero records.

(Whether claude-code skips the export call entirely or sends something that the collector then drops is not directly verified — only the end observation "collector receives nothing" is confirmed.)

There is no warning, error message, or stderr output. The only visible symptom is missing data on the collector side.

Percent-encoding the same value (%ED%95%9C%EA%B8%80%ED%8C%80 instead of 한글팀) makes telemetry flow normally and the value is decoded back to Korean on the collector side. So the data path itself works; the failure happens at env-var parsing inside the bundled @opentelemetry/resources SDK.

Root cause confirmed: the version of @opentelemetry/resources bundled into claude-code 2.1.116 is the old "strict" line (≤ v2.5.1), which performs W3C Baggage octet validation and rejects any character outside 0x210x7E. This was removed in open-telemetry/opentelemetry-js#6261, released in @opentelemetry/resources v2.6.0 (2026-03-03). claude-code's package.json declares "@opentelemetry/resources": "^2.0.0", but the lockfile/bundle is pinned to a pre-fix version.

What Should Happen?

Bump the bundled @opentelemetry/resources to ≥ v2.6.0 (current latest is v2.7.1, released 2026-04-29). This single dependency bump removes the strict octet validation and allows raw non-ASCII values to pass through, matching the behavior of all other OTel SIGs.

Secondary asks:

  • Document the percent-encoding requirement for OTEL_RESOURCE_ATTRIBUTES (until the bump ships, this is the only workaround).
  • Even after the bump, parsing errors are still logged at diag.debug (invisible at default log level) — this is an upstream concern but worth surfacing as a warning at the claude-code layer for env-var misconfigurations.

Error Messages/Logs

(none — failure is silent at default log level; SDK uses diag.debug which is suppressed)

Steps to Reproduce

  1. Start a local OTLP collector (e.g. otelcol-contrib 0.150.1) on :4317/:4318 with a debug exporter (verbosity detailed).

  2. Run claude with raw Korean in OTEL_RESOURCE_ATTRIBUTES:

    export CLAUDE_CODE_ENABLE_TELEMETRY=1
    export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318
    export OTEL_RESOURCE_ATTRIBUTES="team=한글팀,case=raw"
    claude --print "hello"

    → Collector receives 0 records.

  3. Repeat with percent-encoded value:

    export OTEL_RESOURCE_ATTRIBUTES="team=%ED%95%9C%EA%B8%80%ED%8C%80,case=pct"
    claude --print "hello"

    → Collector receives normally; -> team: Str(한글팀) appears in debug output.

The only difference between cases is whether raw UTF-8 bytes are present in the env-var value.

Investigation summary

1. Bundled SDK identified as pre-#6261 (strict)

The minified claude-code 2.1.116 binary still contains the function name _isBaggageOctetString and _parseResourceAttributes:

$ strings /opt/homebrew/Caskroom/claude-code/2.1.116/claude | grep -oE '_isBaggageOctet[^,;)]{0,200}' | head
_isBaggageOctetString(H
_isBaggageOctetString(H

_isBaggageOctetString is the strict W3C Baggage octet check that was deleted by PR #6261. Its presence in the bundle means the locked @opentelemetry/resources is from the strict line — i.e. ≤ v2.5.1 (last release before #6261).

package.json declares "@opentelemetry/resources": "^2.0.0", so the lockfile (or bundling pin) is what's stuck on the old line. A re-resolve at build time would pick up v2.7.x.

2. Standalone repro confirms strict v2.5.1 behavior matches the observed drop

Verbatim port of v2.5.1 EnvDetector parsing logic (source) run on the same inputs:

Inputv2.5.1 (strict, what claude-code uses)v2.7.1 (post-#6261, current main)
team=한글팀,case=raw{} (silent drop){team:'한글팀', case:'raw'}
team=%ED%95%9C...,case=pct{team:'한글팀', case:'pct'}same
team=%ZZ{} (URI malformed){} (URI malformed)
team=mlops,env=prod{team:'mlops', env:'prod'}same

The strict-line drop on raw Korean exactly reproduces the silent failure observed in claude-code.

3. Other failure points ruled out

  • macOS shell → Node process.env: Korean UTF-8 preserved intact across LANG=C, LANG=ko_KR.UTF-8, and unset.
  • decodeURIComponent('한글팀') does not throw.
  • sanitizeAttributes and OTLP toAnyValue transformer in current main have no ASCII-only checks.

So the failure is unambiguously at the bundled-SDK env-var parsing stage.

Related upstream context

Workaround (until the bump ships)

Pre-encode attribute values:

python3 -c "import urllib.parse; print(urllib.parse.quote('한글팀'))"
# %ED%95%9C%EA%B8%80%ED%8C%80

Or via ~/.claude/settings.json:

{
  "env": {
    "OTEL_RESOURCE_ATTRIBUTES": "team=%ED%95%9C%EA%B8%80%ED%8C%80,env=prod"
  }
}

Is this a regression?

I don't know — depends on whether any prior claude-code release ever bundled @opentelemetry/resources ≥ v2.6.0.

Last Working Version

(unknown)

Claude Code Version

2.1.116 (Claude Code)

Build: 2026-04-20T13:57:26Z, GIT_SHA: 9e176d0

Platform

Anthropic API

Operating System

macOS (arm64, Darwin 23.6.0)

Terminal/Shell

iTerm2 (zsh) — not terminal-specific, reproducible across terminals.

Additional Information

  • Local collector config: standard otlp receiver → batch processor → debug exporter (verbosity: detailed).
  • Documentation improvement (separate concern but related): the docs for OTEL_RESOURCE_ATTRIBUTES should call out the percent-encoding requirement and the silent-drop risk for raw non-ASCII values, at least until the SDK bump lands.

extent analysis

TL;DR

Bump the bundled @opentelemetry/resources to ≥ v2.6.0 to fix the issue with raw non-ASCII values in OTEL_RESOURCE_ATTRIBUTES.

Guidance

  • Verify the version of @opentelemetry/resources bundled with claude-code by checking the lockfile or bundle.
  • Update the package.json to specify a version of @opentelemetry/resources that is ≥ v2.6.0.
  • As a temporary workaround, percent-encode non-ASCII values in OTEL_RESOURCE_ATTRIBUTES using a tool like urllib.parse.quote.
  • Test the fix by running claude with raw Korean in OTEL_RESOURCE_ATTRIBUTES and verifying that telemetry records are received by the OTLP collector.

Example

export OTEL_RESOURCE_ATTRIBUTES="team=%ED%95%9C%EA%B8%80%ED%8C%80,case=pct"
claude --print "hello"

Notes

The issue is specific to the version of @opentelemetry/resources bundled with claude-code, and updating to a newer version should resolve the issue. The workaround of percent-encoding non-ASCII values can be used until the update is applied.

Recommendation

Apply the workaround of percent-encoding non-ASCII values in OTEL_RESOURCE_ATTRIBUTES until the bundled @opentelemetry/resources can be updated to ≥ v2.6.0.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - ✅(Solved) Fix [BUG] OTEL_RESOURCE_ATTRIBUTES with raw non-ASCII (Korean) values silently drops all telemetry — bundled @opentelemetry/resources is outdated [1 pull requests, 1 participants]