Skip to content

fix(opentelemetry): use oneOf for metadata additionalProperties value type#13690

Open
shreemaan-abhishek wants to merge 3 commits into
apache:masterfrom
shreemaan-abhishek:fix/otel-resource-additionalproperties
Open

fix(opentelemetry): use oneOf for metadata additionalProperties value type#13690
shreemaan-abhishek wants to merge 3 commits into
apache:masterfrom
shreemaan-abhishek:fix/otel-resource-additionalproperties

Conversation

@shreemaan-abhishek

Copy link
Copy Markdown
Contributor

Description

The opentelemetry plugin's metadata_schema declared additionalProperties for two objects using forms the JSON Schema validator does not recognize, so value-type validation was silently a no-op:

  • resource.additionalProperties used a bare array of schemas: {{type="boolean"}, {type="number"}, {type="string"}}. additionalProperties expects a single schema object, not an array; the validator sees numeric keys instead of a keyword and ignores it.
  • collector.request_headers.additionalProperties used one_of, which is not a JSON Schema keyword (the keyword is oneOf).

In both cases the constraint had no effect, so resource / request_headers values of any type (objects, arrays) passed validation. At runtime only string/number/boolean values are actually consumed, so non-scalar values were silently dropped. This has been present since the plugin was introduced in #6119.

This changes both to the correct oneOf form so non-scalar values are rejected at config time.

Behavior change

plugin_metadata entries whose resource or collector.request_headers hold a non-scalar value are now rejected on write and on load. Such values were already ignored at runtime, so no working telemetry changes; the failure mode moves from "attribute silently dropped" to "invalid metadata rejected", consistent with every other schema.

Tests

Added a test asserting object/array resource values and object request_headers values are rejected (400) while scalar values remain valid. Verified it fails on the current code and passes with the fix.

… type

The resource and collector.request_headers metadata used an invalid
additionalProperties form: resource used a bare array of schemas and
request_headers used one_of, which is not a JSON Schema keyword. The
validator recognizes neither, so value-type validation was a no-op and
values of any type passed. Switch both to oneOf so non-scalar values are
rejected.
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. bug Something isn't working labels Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants