Skip to content

Handle invalid response JSON with SDK diagnostics - #87

Open
tim-kos wants to merge 2 commits into
mainfrom
fix/invalid-response-json
Open

tim-kos wants to merge 2 commits into
mainfrom
fix/invalid-response-json

Conversation

@tim-kos

@tim-kos tim-kos commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

HTML proxy errors currently expose a parser exception when callers access a response body. Valid JSON is also reparsed on every access.

Memoize parsed bodies and invalidate them on response replacement. Wrap JSON parse failures in Transloadit::Exception::InvalidResponse, exposing HTTP status, raw body, and parser cause while keeping the message free of response contents. Explicitly reject empty/whitespace bodies because some MultiJson adapters accept them as nil. Preserve valid array, null, and false bodies.

Validation: full Ruby 3.3 suite passes (131 tests, 268 assertions; optional live-upload and signature-parity tests skipped), plus bundle exec standardrb and git diff --check. Tests cover single parsing, cache invalidation, HTML and empty responses, diagnostic access, parser causes, and existing non-object JSON behavior.

Compatibility: constrain JSON to versions below 3 because Ruby 3.1 resolves MultiJson 1.19, whose positional parsing options are incompatible with JSON 3. This dependency constraint is shared across the four independent fixes.

The four fixes also merge together cleanly. Their combined Ruby 3.3 suite passes with Node signature parity enabled: 147 tests, 321 assertions, with only the optional live upload skipped.

@codecov-commenter

codecov-commenter commented Oct 13, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.42%. Comparing base (79535b2) to head (543e676).

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #87      +/-   ##
==========================================
+ Coverage   99.40%   99.42%   +0.02%     
==========================================
  Files           9        9              
  Lines         336      348      +12     
  Branches       38       41       +3     
==========================================
+ Hits          334      346      +12     
  Misses          1        1              
  Partials        1        1              

☔ 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.

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.

2 participants