Skip to content

fix(proto): accept null AnyValue fields in OTLP JSON - #3603

Closed
bruno-espino wants to merge 2 commits into
open-telemetry:mainfrom
pydantic:fix/otlp-json-null-anyvalue
Closed

fix(proto): accept null AnyValue fields in OTLP JSON#3603
bruno-espino wants to merge 2 commits into
open-telemetry:mainfrom
pydantic:fix/otlp-json-null-anyvalue

Conversation

@bruno-espino

@bruno-espino bruno-espino commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Changes

The ProtoJSON mapping requires parsers to accept null for any field and leave that field unset. The AnyValue protobuf definition permits its oneof to remain unset.

The custom AnyValue visitor introduced in #1753 deserializes recognized fields directly into their concrete type. As a result, {"intValue":null} fails with data did not match any variant of untagged enum StringOrInt instead of producing an empty AnyValue. This happens before the empty-value handling fixed in #3595, so it is a separate pre-existing case.

This occurs in real exporter traffic: the Vercel AI SDK can emit doubleValue: null for non-finite token attributes, and PostHog independently encountered whole-request failures in opentelemetry-proto and merged a receiver-side workaround that removes null-valued AnyValue fields before deserialization.

Deserialize each recognized field through Option, treating null as unset while preserving normal validation for non-null values. Regression coverage includes every AnyValue variant.

This was also tested through an OTLP receiver's JSON ingest path: upstream main rejected {"intValue":null} with the StringOrInt error; with this change it decodes as an unset value, while a fractional intValue remains rejected.

Merge requirement checklist

  • CONTRIBUTING guidelines followed
  • Unit tests added/updated
  • Appropriate CHANGELOG.md updated
  • No public API changes

@bruno-espino
bruno-espino requested a review from a team as a code owner July 22, 2026 21:25
@codecov

codecov Bot commented Jul 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.2%. Comparing base (0e78170) to head (c21c95a).
⚠️ Report is 11 commits behind head on main.

Additional details and impacted files
@@          Coverage Diff          @@
##            main   #3603   +/-   ##
=====================================
  Coverage   83.2%   83.2%           
=====================================
  Files        130     130           
  Lines      28246   28246           
=====================================
  Hits       23506   23506           
  Misses      4740    4740           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bruno-espino bruno-espino changed the title Accept null AnyValue fields in OTLP JSON fix(proto): accept null AnyValue fields in OTLP JSON Jul 22, 2026
@bruno-espino

bruno-espino commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

The integration test failure appears unrelated to this change, could a maintainer please rerun the failed job?

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown

Thank you for your contribution! This PR has been automatically marked as stale because it has not had activity in the last 14 days. This may be due to a delay in review on our side or awaiting a response from you; either is fine, and we appreciate your patience.

It will be closed in 14 days if no further activity occurs. Pushing a new commit or leaving a comment will remove the stale label and keep the PR open.

@github-actions

Copy link
Copy Markdown

Closed as inactive. Thank you again for the contribution; please feel free to reopen this PR (or open a new one) if you'd like to continue the work.

@github-actions github-actions Bot closed this Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant