jackwener/OpenCLI · error · CommandExecutionError

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

Error message

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

What it means

Catch-all for any non-OK HTTP status from Wikidata that is not specifically handled as 404 or 429 (e.g. 500, 502, 503, 403). wikidataFetch throws a CommandExecutionError carrying the raw status code, since anonymous users rarely need differentiated handling beyond 'the request failed server-side'.

Source

Thrown at clis/wikidata/utils.js:82

        resp = await fetch(url, { headers: { 'user-agent': UA, accept: 'application/json' } });
    }
    catch (err) {
        throw new CommandExecutionError(
            `${label} request failed: ${err?.message ?? err}`,
            'Check that www.wikidata.org is reachable from this network.',
        );
    }
    if (resp.status === 404) {
        throw new EmptyResultError(label, `Wikidata returned 404 for ${url}.`);
    }
    if (resp.status === 429) {
        throw new CommandExecutionError(
            `${label} returned HTTP 429 (rate limited)`,
            'Wikidata throttles anonymous traffic; back off 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;
}

/**
 * Pick a localised label / description from a `{<lang>: {value}}` map.
 * Falls back to English if the requested language is missing.
 */
export function pickLocalised(map, language) {
    if (!map || typeof map !== 'object') return null;
    const direct = map[language];

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Retry after a short delay — 5xx is usually transient
  2. Check the Wikidata/Wikimedia status page for an ongoing incident
  3. Log the full URL and status; verify the request is not being intercepted by a proxy or firewall
  4. If status is 403, review your User-Agent and request volume against Wikimedia's User-Agent policy

Example fix

// before
const body = await wikidataFetch(url, 'search');
// after
try {
  const body = await wikidataFetch(url, 'search');
} catch (err) {
  if (/HTTP 5\d\d/.test(String(err.message))) {
    await new Promise(r => setTimeout(r, 2000));
    return retry(); // transient server error
  }
  throw err;
}
Defensive patterns

Strategy: retry

Try / catch

try {
  const body = await wikidataFetch(url, label);
} catch (err) {
  if (/HTTP [5]/.test(String(err.message))) {
    await new Promise(r => setTimeout(r, 2000));
    return wikidataFetch(url, label); // retry transient 5xx
  }
  throw err;
}

Prevention

When it happens

Trigger: Wikidata returning 5xx during an outage or maintenance; a 403 from aggressive/abusive-traffic filtering on the shared UA; HTTP-level redirects or proxy interference producing unexpected statuses.

Common situations: Wikidata service incidents (check wikitech status); corporate proxies or firewalls rewriting responses; making requests during known maintenance windows.

Related errors


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