Skip to content

Resource attribute decoding corrupts unencoded non-ASCII characters #8890

Closed

Description

@thswlsqls

Describe the bug
When an OTEL_RESOURCE_ATTRIBUTES value contains both a percent-encoded sequence and an unencoded non-ASCII character, the non-ASCII character is corrupted.

Steps to reproduce
Set OTEL_RESOURCE_ATTRIBUTES=key=café%20bar (or -Dotel.resource.attributes=key=café%20bar) and build the SDK with autoconfigure.

What did you expect to see?
key="café bar". The spec only requires , and = to be percent-encoded, so an unencoded é is valid input. Before #8059, URLDecoder kept such characters.

What did you see instead?
key="caf� bar". EnvironmentResource.decodeResourceAttributes() writes each unencoded char into a byte array with (byte) c and decodes the array as UTF-8, so any char at or above U+0080 is truncated. Values without % skip decoding and are not affected.

What version and what artifacts are you using?
Artifacts: opentelemetry-sdk-extension-autoconfigure (also declarative config resource.attributes_list, which uses a copy of this class)
Version: 1.60.0 through 1.66.0, main @ 7f423cb
How did you reference these artifacts? N/A

Environment
Compiler: Temurin 21
OS: N/A

Additional context
Regression from #8059, which replaced URLDecoder to keep + as a literal (#8030).
Spec: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/sdk.md#specifying-resource-information-via-an-environment-variable

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

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions