jackwener/OpenCLI · error · CommandExecutionError

Malformed JSON from OpenReview for ${label}: ${e?.message ??

Error message

Malformed JSON from OpenReview for ${label}: ${e?.message ?? e}

What it means

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.

Source

Thrown at clis/openreview/utils.js:95

        resp = await fetch(url);
    }
    catch (e) {
        throw new CommandExecutionError(`Network failure fetching ${label}: ${e?.message ?? e}`, 'Check your network connection and try again.');
    }
    if (resp.status === 404) {
        return null;
    }
    if (!resp.ok) {
        let body = '';
        try { body = (await resp.text()).slice(0, 200); } catch {}
        throw new CommandExecutionError(`OpenReview API HTTP ${resp.status} for ${label}${body ? ` (${body})` : ''}`, 'The OpenReview API may be down or rate-limiting.');
    }
    let json;
    try {
        json = await resp.json();
    }
    catch (e) {
        throw new CommandExecutionError(`Malformed JSON from OpenReview for ${label}: ${e?.message ?? e}`, 'Try again or report this as an OpenReview API bug.');
    }
    const envelopeErrors = Array.isArray(json?.errors) ? json.errors.filter(Boolean) : [];
    const envelopeError = typeof json?.error === 'string' ? json.error.trim() : '';
    if (envelopeErrors.length || envelopeError) {
        const detail = envelopeError || envelopeErrors.map((entry) => {
            if (typeof entry === 'string') return entry;
            if (entry?.message) return String(entry.message);
            return JSON.stringify(entry);
        }).join('; ');
        throw new CommandExecutionError(`OpenReview API error for ${label}: ${detail}`, 'The OpenReview API returned an application-level error.');
    }
    return json;
}

/** Format ms-since-epoch as YYYY-MM-DD; empty string for invalid input. */
export function formatDate(ms) {
    if (typeof ms !== 'number' || !Number.isFinite(ms) || ms <= 0) return '';
    return new Date(ms).toISOString().slice(0, 10);

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Retry the request; this is usually transient.
  2. Inspect the raw response (curl the same URL) to see what was actually returned.
  3. Check proxy/TLS interception settings that may alter response bodies.

Example fix

// before
const json = await openreviewFetch(path, label);
// after
try { var json = await openreviewFetch(path, label); }
catch (e) { if (/Malformed JSON/.test(e.message)) { await sleep(1000); return openreviewFetch(path, label); } throw e; }
Defensive patterns

Strategy: retry

Try / catch

try { const json = await openreviewFetch(path, label); }
catch (e) { if (/Malformed JSON/.test(e.message)) { await sleep(1000); return openreviewFetch(path, label); } throw e; }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "Invalid JSON response" and "Failed to parse response" errors: when an API answers 200 but the body isn't the JSON your library expected — this error's family across 28 libraries.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/f2b9a62e06511749. Report an issue: GitHub.