jackwener/OpenCLI · error · CommandExecutionError

${label} returned HTTP ${resp.status}

Error message

${label} returned HTTP ${resp.status}

What it means

After handling 404 and 429, oeisFetch checks resp.ok and throws this CommandExecutionError for any other non-2xx status (e.g. 500, 502, 503). The message includes the exact HTTP status and the resource label. This catches server-side or unexpected upstream errors.

Source

Thrown at clis/oeis/utils.js:64

export async function oeisFetch(url, label) {
    let resp;
    try {
        resp = await fetch(url, { headers: { 'user-agent': UA, accept: 'application/json' } });
    }
    catch (err) {
        throw new CommandExecutionError(
            `${label} request failed: ${err?.message ?? err}`,
            'Check that oeis.org is reachable from this network.',
        );
    }
    if (resp.status === 404) {
        throw new EmptyResultError(label, `OEIS returned 404 for ${url}.`);
    }
    if (resp.status === 429) {
        throw new CommandExecutionError(`${label} returned HTTP 429 (rate limited)`);
    }
    if (!resp.ok) {
        throw new CommandExecutionError(`${label} returned HTTP ${resp.status}`);
    }
    let body;
    try {
        body = await resp.json();
    }
    catch (err) {
        throw new CommandExecutionError(`${label} returned malformed JSON: ${err?.message ?? err}`);
    }
    return body;
}

/** Format OEIS' `number: 40` into the canonical zero-padded id `A000040`. */
export function formatId(number) {
    if (typeof number !== 'number' || !Number.isInteger(number) || number < 0) return null;
    return `A${String(number).padStart(6, '0')}`;
}

/** Take the first N comma-separated terms from OEIS' `data` string. */

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Retry later — 5xx usually indicates a server-side outage.
  2. Check oeis.org in a browser to see if the site is up.
  3. Inspect the status code in the message to decide whether to retry (5xx) or fix the request (4xx).

Example fix

// retry on transient status
try {
  return await oeisFetch(url, label);
} catch (e) {
  if (String(e.message).includes('HTTP 5')) return await oeisFetch(url, label);
  throw e;
}
Defensive patterns

Strategy: retry

Validate before calling

null

Type guard

null

Try / catch

try { return await oeisFetch(url, label); }
catch (e) {
  const m = String(e.message).match(/HTTP (\d+)/);
  if (m && +m[1] >= 500) return await oeisFetch(url, label); // retry transient 5xx
  throw e;
}

Prevention

When it happens

Trigger: oeis.org returning 5xx during an outage or maintenance, an unexpected 403 from an edge/WAF rule, or any status other than 200/404/429.

Common situations: OEIS server downtime, transient gateway errors (502/503 from a reverse proxy), or an API endpoint changing and rejecting old request shapes.

Related errors


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