Skip to content

fix(otlp-transformer): add check for possible unsafe json parse#6588

Merged
maryliag merged 4 commits intoopen-telemetry:mainfrom
maryliag:parse-check
Apr 14, 2026
Merged

fix(otlp-transformer): add check for possible unsafe json parse#6588
maryliag merged 4 commits intoopen-telemetry:mainfrom
maryliag:parse-check

Conversation

@maryliag
Copy link
Copy Markdown
Contributor

JSON.parse() on server responses without try/catch will throw on malformed data, potentially crashing the process

@maryliag maryliag requested a review from a team as a code owner April 13, 2026 16:14
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.76%. Comparing base (36ce569) to head (77505f6).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6588   +/-   ##
=======================================
  Coverage   95.75%   95.76%           
=======================================
  Files         375      375           
  Lines       12725    12737   +12     
  Branches     3013     3013           
=======================================
+ Hits        12185    12197   +12     
  Misses        540      540           
Files with missing lines Coverage Δ
...al/packages/otlp-transformer/src/logs/json/logs.ts 100.00% <100.00%> (ø)
...kages/otlp-transformer/src/metrics/json/metrics.ts 100.00% <100.00%> (ø)
.../packages/otlp-transformer/src/trace/json/trace.ts 100.00% <100.00%> (ø)
🚀 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.

Comment thread experimental/packages/otlp-transformer/src/logs/json/logs.ts
@maryliag maryliag enabled auto-merge April 14, 2026 15:22
@maryliag maryliag added this pull request to the merge queue Apr 14, 2026
Merged via the queue into open-telemetry:main with commit f40fd24 Apr 14, 2026
27 checks passed
@maryliag maryliag deleted the parse-check branch April 14, 2026 15:46
@trentm
Copy link
Copy Markdown
Contributor

trentm commented Apr 15, 2026

potentially crashing the process

It looks to me like the only caller of this is wrapping in a try/catch already.

this._serializer.deserializeResponse(response.data)

Perhaps it is more appropriate for an exception to be caught in the caller? I haven't looked closely.

maryliag added a commit to maryliag/opentelemetry-js that referenced this pull request Apr 17, 2026
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.

3 participants