Repository navigation
Fix crash on non-JSON error response body - #2234
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthroughThe HTTP request paths now propagate invalid JSON errors for successful responses and convert invalid JSON in error responses into ChangesResponse Parsing
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to The response-handling change has no identified actionable merge risk. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2234 +/- ##
==========================================
+ Coverage 98.14% 98.15% +0.01%
==========================================
Files 14 14
Lines 700 706 +6
Branches 110 106 -4
==========================================
+ Hits 687 693 +6
Misses 12 12
Partials 1 1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Bare JSON.parse threw a raw SyntaxError instead of MeilisearchApiError when the server (or a proxy) returned a non-JSON body. Parse via a helper that falls back to undefined, so error responses surface as MeilisearchApiError with 'status: statusText'.
7acacc8 to
3393171
Compare
When the server (or a proxy in front of it) returns a non-JSON error body — e.g. an nginx
502 Bad GatewayHTML page — the client threw a rawSyntaxError: Unexpected token '<'...instead of aMeilisearchApiError, so callers couldn't handle it as a normal API error.This parses the body defensively (falling back to
undefined, like the empty-body case already did) so error responses always surface asMeilisearchApiErrorwith the HTTP status. Same symptom as #1892.Testing
vitest run tests/http-requests.test.ts— 8 passed.tsc --noEmit,oxlint, andprettier --checkclean.Summary by CodeRabbit
Bug Fixes
Tests