Skip to content

fix(otlp): split OTLP headers on first = only - #22201

Closed
robertyates wants to merge 1 commit into
anomalyco:devfrom
robertyates:fix/otlp-header-parsing-v2
Closed

robertyates wants to merge 1 commit into
anomalyco:devfrom
robertyates:fix/otlp-header-parsing-v2

Conversation

@robertyates

@robertyates robertyates commented Apr 12, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #22202

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

The OTLP header parser in oltp.ts uses x.split("=") with destructuring, which splits on every = in the string. When the header value itself contains = (e.g. Sentry's x-sentry-auth=sentry sentry_key=abc123), the actual key gets silently dropped.

Fixed by splitting on the first = only via indexOf + slice.

How did you verify your code works?

Ran opencode serve with OTEL_EXPORTER_OTLP_ENDPOINT and OTEL_EXPORTER_OTLP_HEADERS set to a Sentry OTLP endpoint. Before the fix: traces silently fail (401). After: traces land in Sentry.

Screenshots / recordings

N/A — not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

`OTEL_EXPORTER_OTLP_HEADERS` values can contain `=` in the value
portion (e.g. Sentry's `x-sentry-auth=sentry sentry_key=KEY`).

The previous `x.split("=")` with array destructuring `[key, value]`
splits on every `=` and silently drops everything after the second
one, causing authentication failures.

Fix: use `indexOf("=")` + `slice` to split only on the first `=`,
preserving the full value.
@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Apr 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions github-actions Bot removed needs:issue needs:compliance This means the issue will auto-close after 2 hours. labels Apr 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@robertyates

Copy link
Copy Markdown
Author

Closing — this was fixed independently in #22564 by @thdxr and shipped in v1.4.6. Thanks!

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.

OTLP header parsing breaks when value contains = (e.g. Sentry's)

1 participant