Description
In lib/github.ts:272-275, the fetchGraphQLWithRetry function calls res.clone().json() to detect GraphQL-level rate-limit errors in the response body. If JSON parsing fails (malformed body, empty response, unexpected content-type from GitHub), the rejection is silently swallowed by .catch(() => null) with no logging.
Impact
When the GitHub GraphQL API returns a non-standard response format, the isBodyRateLimited check (lines 276-282) gracefully degrades (short-circuits on null), but the absence of any error logging creates a debugging black hole:
- No warning or error is emitted when body parsing fails
- The function silently proceeds to return the response
- The only visible symptom is a downstream cryptic error (e.g., "profile fetch failed"), leaving no breadcrumb trail pointing back to the response parsing failure
Current Code
const body: unknown = await res
.clone()
.json()
.catch(() => null);
Suggested Fix
const body: unknown = await res
.clone()
.json()
.catch((err) => {
console.warn('[GitHub API] Failed to parse rate-limit response body:', err?.message ?? err);
return null;
});
Acceptance Criteria
Severity
Medium — not a crash, but a significant debug-ability gap that delays incident response.
Related
Similar patterns exist at lib/github.ts:680 and lib/github.ts:970 with the same issue.
Description
In
lib/github.ts:272-275, thefetchGraphQLWithRetryfunction callsres.clone().json()to detect GraphQL-level rate-limit errors in the response body. If JSON parsing fails (malformed body, empty response, unexpected content-type from GitHub), the rejection is silently swallowed by.catch(() => null)with no logging.Impact
When the GitHub GraphQL API returns a non-standard response format, the
isBodyRateLimitedcheck (lines 276-282) gracefully degrades (short-circuits onnull), but the absence of any error logging creates a debugging black hole:Current Code
Suggested Fix
Acceptance Criteria
res.clone().json()rejects, a warning is logged with error detailsnullis preservedSeverity
Medium — not a crash, but a significant debug-ability gap that delays incident response.
Related
Similar patterns exist at
lib/github.ts:680andlib/github.ts:970with the same issue.