jackwener/OpenCLI · error · CommandExecutionError

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

Error message

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

What it means

The catch-all branch of rawFetch at clis/goproxy/utils.js:78: any non-ok response that isn't 404/410/429 (e.g. 500, 502, 503, 403) is raised as a CommandExecutionError with the status code in the message, so unexpected proxy responses surface clearly.

Source

Thrown at clis/goproxy/utils.js:78

async function rawFetch(url, label) {
    let resp;
    try {
        resp = await fetch(url, { headers: { 'user-agent': UA } });
    }
    catch (err) {
        throw new CommandExecutionError(
            `${label} request failed: ${err?.message ?? err}`,
            'Check that proxy.golang.org is reachable from this network.',
        );
    }
    if (resp.status === 404 || resp.status === 410) {
        throw new EmptyResultError(label, `proxy.golang.org returned ${resp.status} 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}`);
    }
    return resp;
}

export async function goproxyJson(url, label) {
    const resp = await rawFetch(url, label);
    let body;
    try {
        body = await resp.json();
    }
    catch (err) {
        throw new CommandExecutionError(`${label} returned malformed JSON: ${err?.message ?? err}`);
    }
    return body;
}

export async function goproxyText(url, label) {
    const resp = await rawFetch(url, label);

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Check https://status.go.dev or proxy reachability with `curl -I https://proxy.golang.org` for the same status code.
  2. Retry once or twice with backoff for transient 5xx (502/503/504).
  3. Investigate any in-path proxy/firewall if you see 403/451 that curl doesn't reproduce.
  4. If the proxy is down, fall back to `go list -m -versions` via a direct VCS fetch (GOPROXY=direct) for that module.

Example fix

// before
const info = await goproxyVersionInfo(mod, tag);   // 503 during outage
// after
let info;
for (let i = 0; i < 3 && !info; i++) {
  try { info = await goproxyVersionInfo(mod, tag); }
  catch (e) { await new Promise(r => setTimeout(r, 2 ** i * 500)); }
}
Defensive patterns

Strategy: retry

Validate before calling

null

Type guard

null

Try / catch

try {
  return await goproxyText(url, label);
} catch (err) {
  const m = err instanceof CommandExecutionError && /HTTP (5\d\d)/.exec(err.message);
  if (m) {
    // transient proxy outage: retry with backoff, then fall back to GOPROXY=direct
    await new Promise(r => setTimeout(r, 3000));
    return goproxyText(url, label);
  }
  throw err;
}

Prevention

When it happens

Trigger: proxy.golang.org returning 5xx during an outage or degraded state; a middlebox/CDN returning 403 or 451; TLS-terminating proxies injecting error pages with odd statuses; transient 502/504 from upstream.

Common situations: Go proxy incidents/outages; corporate SSL appliances blocking the UA or domain; regional blocks (451); brief upstream hiccups during peak load.

Related errors


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