Skip to content

[fix][backend] accept string-encoded intValue in OTLP/JSON ingestion - #649

Open
kidkidkid wants to merge 1 commit into
mainfrom
lzp/fix_otlp_intvalue_string
Open

kidkidkid wants to merge 1 commit into
mainfrom
lzp/fix_otlp_intvalue_string

Conversation

@kidkidkid

Copy link
Copy Markdown
Collaborator

OTLP/JSON (proto3 JSON mapping) encodes int64/uint64/fixed64/sfixed64 as string, e.g. {"intValue":"42"}. Standard OTel SDKs (Rust/Go/Python) emit this form. AnyValue.UnmarshalJSON only decoded intValue as a JSON number, so any span attribute carrying an int (thread.id, code.line.number, token counts) failed the whole request with 600904004 "json Unmarshal err".

Fall back to parsing the string form when numeric decode fails; keep the numeric path for the PB->JSON internal shape. Non-numeric strings still error. Add unit tests for the string-encoded, negative and invalid cases.

What type of PR is this?

Check the PR title

  • This PR title match the format: [<type>][<scope>] <description>. For example: [fix][backend] flaky fix
  • The description of this PR title is user-oriented and clear enough for others to understand.
  • Add documentation if the current PR requires user awareness at the usage level.
  • This PR is written in English. PRs not in English will not be reviewed.

(Optional) Translate the PR title into Chinese

(Optional) More detailed description for this PR(en: English/zh: Chinese)

en:
zh(optional):

(Optional) Which issue(s) this PR fixes

OTLP/JSON (proto3 JSON mapping) encodes int64/uint64/fixed64/sfixed64 as
string, e.g. {"intValue":"42"}. Standard OTel SDKs (Rust/Go/Python) emit
this form. AnyValue.UnmarshalJSON only decoded intValue as a JSON number,
so any span attribute carrying an int (thread.id, code.line.number, token
counts) failed the whole request with 600904004 "json Unmarshal err".

Fall back to parsing the string form when numeric decode fails; keep the
numeric path for the PB->JSON internal shape. Non-numeric strings still
error. Add unit tests for the string-encoded, negative and invalid cases.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@codecov

codecov Bot commented Sep 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #649   +/-   ##
=======================================
  Coverage   78.48%   78.48%           
=======================================
  Files         696      696           
  Lines       85978    85978           
=======================================
+ Hits        67476    67480    +4     
+ Misses      14568    14566    -2     
+ Partials     3934     3932    -2     
Flag Coverage Δ
unittests 78.48% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 3 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2d02f40...eda1f3e. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

1 participant