Skip to content

Check Content-Type before parsing error responses as JSON#8641

Merged
iHiD merged 1 commit into
mainfrom
fix/8633
Feb 13, 2026
Merged

Check Content-Type before parsing error responses as JSON#8641
iHiD merged 1 commit into
mainfrom
fix/8633

Conversation

@iHiD
Copy link
Copy Markdown
Member

@iHiD iHiD commented Feb 13, 2026

Closes #8633
Closes #8632
Closes #8628

Summary

  • When a non-JSON response (rate limit "Retry later", HTML error page, binary data) was thrown by fetchJSON, useErrorHandler in ErrorBoundary.tsx unconditionally called .json() on it, producing a SyntaxError that was reported to Sentry
  • Now checks the Content-Type header first and only attempts JSON parsing when the response claims to be JSON — mirrors the same check already used in fetch-json.ts
  • Non-JSON error responses skip straight to showing the default error message (same user-visible behavior as before)

Test plan

  • yarn test — all 160 suites pass (1551 tests), no regressions
  • TypeScript type check — no new errors (same 14 pre-existing errors in react-i18next)
  • Pre-commit hooks pass (prettier)

🤖 Generated with Claude Code

When a non-JSON response (rate limit "Retry later", HTML error page,
binary data) was thrown by fetchJSON, useErrorHandler unconditionally
called .json() on it, producing a SyntaxError that was reported to
Sentry. Now we check the Content-Type header first and only attempt
JSON parsing when the response claims to be JSON.

Closes #8633
Closes #8632
Closes #8628

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@iHiD iHiD requested a review from dem4ron as a code owner February 13, 2026 12:49
@iHiD iHiD merged commit 4d40bd1 into main Feb 13, 2026
41 checks passed
@iHiD iHiD deleted the fix/8633 branch February 13, 2026 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant