From 974a2a023e1eeaae6e41f29d8301487b4db87631 Mon Sep 17 00:00:00 2001 From: "sentry[bot]" <39604003+sentry[bot]@users.noreply.github.com> Date: Fri, 28 Aug 2026 10:48:43 +0000 Subject: [PATCH] fix: Prevent JSON SyntaxError on non-2xx API responses --- src/service.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/service.ts b/src/service.ts index d347127..3c6aeaa 100644 --- a/src/service.ts +++ b/src/service.ts @@ -110,6 +110,11 @@ export class Codecov { Referrer: referrer, }, }); + + if (!response.ok) { + return { ok: false, data: null }; + } + const data = await response.json(); return { @@ -134,6 +139,11 @@ export class Codecov { Referrer: referrer, }, }); + + if (!response.ok) { + return { ok: false, data: null }; + } + const data = await response.json(); return { @@ -211,6 +221,11 @@ export class Codecov { Referrer: referrer, }, }); + + if (!response.ok) { + return { ok: false, data: null }; + } + const data = await response.json(); await this.setCached("flags", owner, repo, data); @@ -244,6 +259,11 @@ export class Codecov { Referrer: referrer, }, }); + + if (!response.ok) { + return { ok: false, data: null }; + } + const data = await response.json(); await this.setCached("components", owner, repo, data);