jackwener/OpenCLI · error · CommandExecutionError

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

Error message

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

What it means

CommandExecutionError thrown by pypiFetch when the response status is not ok and is not one of the specially-handled codes (404, 429) — e.g. 500, 502, 503. The message carries the label and the raw status code. It indicates a server-side problem rather than bad input.

Source

Thrown at clis/pypi/utils.js:45

        resp = await fetch(url, { headers: { 'user-agent': UA, accept: 'application/json' } });
    }
    catch (err) {
        throw new CommandExecutionError(
            `${label} request failed: ${err?.message ?? err}`,
            'Check that pypi.org / pypistats.org are reachable from this network.',
        );
    }
    if (resp.status === 404) {
        throw new EmptyResultError(label, `PyPI returned 404 for ${url}.`);
    }
    if (resp.status === 429) {
        throw new CommandExecutionError(
            `${label} returned HTTP 429 (rate limited)`,
            'PyPI throttles unauthenticated bursts; wait a few seconds and retry.',
        );
    }
    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;
}

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Retry after a short delay — most 5xx are transient
  2. Check PyPI status page for ongoing incidents
  3. Bypass local proxies/CDN caches if suspected
  4. Report persistent errors to your network team if a proxy is interfering

Example fix

// shell before/after
# before
pypi package requests   # 502 during CDN incident
# after
sleep 5 && pypi package requests
Defensive patterns

Strategy: retry

Validate before calling

null

Type guard

null

Try / catch

try {
  const pkg = await pypiPackage(name);
} catch (e) {
  if (/HTTP 5\d\d/.test(e.message)) {
    // transient server-side failure: retry with backoff
  } else throw e;
}

Prevention

When it happens

Trigger: Any pypiFetch call receiving 5xx or other unexpected statuses: PyPI outages, CDN/ Fastly errors (502/503), gateway misconfigurations, or rare 3xx handled as non-ok by fetch redirects settings.

Common situations: Running the command during a PyPI incident (check pypistatus); transient CDN errors; aggressive caching proxies returning 5xx.

Related errors


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