Skip to content

opentelemetry: OTEL_RESOURCE_ATTRIBUTES parsing drops values containing equals signs #9277

Closed

Description

@okarin1511

What version of Effect is running?

4.12.7 (@effect/opentelemetry)

What steps can reproduce the bug?

Set OTEL_RESOURCE_ATTRIBUTES with a value that contains =:

OTEL_RESOURCE_ATTRIBUTES="service.name=my-app,auth.token=abc=def==,callback.url=https://example.com?a=1&b=2"

The auth.token and callback.url attributes are silently dropped from the resource.

What is the expected behavior?

All three attributes should be present. The OTEL Environment Variable Spec defines the format as key1=value1,key2=value2 where only the first = separates key from value. Values containing = (base64 strings, URLs with query params) are valid.

What do you see instead?

Only service.name=my-app is parsed. The other two entries are silently dropped.

Where it happens

packages/opentelemetry/src/Resource.ts, lines 126-128:

const parts = attr.split("=")
if (parts.length !== 2) {
  return acc
}

split("=") produces more than 2 parts when the value itself contains =, so the parts.length !== 2 check drops the entry.

Suggested fix

Split only on the first = using indexOf and substring:

const eqIndex = attr.indexOf("=")
if (eqIndex === -1) return acc
const key = attr.substring(0, eqIndex).trim()
const value = attr.substring(eqIndex + 1).trim()

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions