{"record":{"id":"f2b9a62e06511749","repo":"jackwener/OpenCLI","slug":"malformed-json-from-openreview-for-label-e","errorCode":null,"errorMessage":"Malformed JSON from OpenReview for ${label}: ${e?.message ?? e}","messagePattern":"Malformed JSON from OpenReview for (.+?): (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/openreview/utils.js","lineNumber":95,"sourceCode":"        resp = await fetch(url);\n    }\n    catch (e) {\n        throw new CommandExecutionError(`Network failure fetching ${label}: ${e?.message ?? e}`, 'Check your network connection and try again.');\n    }\n    if (resp.status === 404) {\n        return null;\n    }\n    if (!resp.ok) {\n        let body = '';\n        try { body = (await resp.text()).slice(0, 200); } catch {}\n        throw new CommandExecutionError(`OpenReview API HTTP ${resp.status} for ${label}${body ? ` (${body})` : ''}`, 'The OpenReview API may be down or rate-limiting.');\n    }\n    let json;\n    try {\n        json = await resp.json();\n    }\n    catch (e) {\n        throw new CommandExecutionError(`Malformed JSON from OpenReview for ${label}: ${e?.message ?? e}`, 'Try again or report this as an OpenReview API bug.');\n    }\n    const envelopeErrors = Array.isArray(json?.errors) ? json.errors.filter(Boolean) : [];\n    const envelopeError = typeof json?.error === 'string' ? json.error.trim() : '';\n    if (envelopeErrors.length || envelopeError) {\n        const detail = envelopeError || envelopeErrors.map((entry) => {\n            if (typeof entry === 'string') return entry;\n            if (entry?.message) return String(entry.message);\n            return JSON.stringify(entry);\n        }).join('; ');\n        throw new CommandExecutionError(`OpenReview API error for ${label}: ${detail}`, 'The OpenReview API returned an application-level error.');\n    }\n    return json;\n}\n\n/** Format ms-since-epoch as YYYY-MM-DD; empty string for invalid input. */\nexport function formatDate(ms) {\n    if (typeof ms !== 'number' || !Number.isFinite(ms) || ms <= 0) return '';\n    return new Date(ms).toISOString().slice(0, 10);","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/openreview/utils.js#L77-L113","documentation":"openreviewFetch throws CommandExecutionError when the HTTP response body cannot be parsed as JSON (resp.json() rejects). This indicates the API returned truncated, empty, or HTML (e.g. a gateway error page) content instead of JSON. The underlying parse error message is embedded for diagnosis.","triggerScenarios":"resp.json() throws: response body is HTML from a proxy/load-balancer error page, connection cut mid-body, gzip corruption, or an empty 200 response.","commonSituations":"Intermittent proxy interference; CDN or load balancer returning an error page with status 200; network interruption during transfer; OpenReview API returning malformed output under load.","solutions":["Retry the request; this is usually transient.","Inspect the raw response (curl the same URL) to see what was actually returned.","Check proxy/TLS interception settings that may alter response bodies."],"exampleFix":"// before\nconst json = await openreviewFetch(path, label);\n// after\ntry { var json = await openreviewFetch(path, label); }\ncatch (e) { if (/Malformed JSON/.test(e.message)) { await sleep(1000); return openreviewFetch(path, label); } throw e; }","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { const json = await openreviewFetch(path, label); }\ncatch (e) { if (/Malformed JSON/.test(e.message)) { await sleep(1000); return openreviewFetch(path, label); } throw e; }","preventionTips":["Retry transient parse failures once or twice.","Bypass suspicious proxies that rewrite response bodies.","Log the raw response body when debugging.","Keep the HTTP client (Node version) current."],"tags":["json","parse-error","api-response"],"backgroundTag":"invalid-json-response","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}