Skip to content

fix: Prevent JSON SyntaxError on non-2xx API responses - #165

Open
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/prevent-json-syntax-error
Open

fix: Prevent JSON SyntaxError on non-2xx API responses#165
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/prevent-json-syntax-error

Conversation

@sentry

@sentry sentry Bot commented Aug 28, 2026

Copy link
Copy Markdown

The browser extension was encountering SyntaxError: Unexpected token 'F', "Forbidden" is not valid JSON when making API calls to Codecov. This occurred because the Codecov API returns a plain-text "Forbidden" message with a 403 status code when authentication or authorization fails. The fetchCommitReport, fetchPRComparison, listFlags, and listComponents methods in src/service.ts were unconditionally calling response.json() on these non-JSON responses, leading to the error.

This fix modifies these four methods to check response.ok before attempting to parse the response as JSON. If response.ok is false, the methods now return { ok: false, data: null }, preventing the SyntaxError and allowing upstream callers (which already handle ok: false) to gracefully manage the API error.

Fixes BROWSER-EXTENSION-RM

This PR was automatically generated by Sentry. You can adjust this setting at any time.

@codecov

codecov Bot commented Aug 28, 2026

Copy link
Copy Markdown

Bundle Report

Changes will increase total bundle size by 245 bytes (0.04%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
codecov-browser-extension-array-push 660.71kB 245 bytes (0.04%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: codecov-browser-extension-array-push

Assets Changed:

Asset Name Size Change Total Size Change (%)
background.js 245 bytes 207.9kB 0.12%

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.

0 participants