{"record":{"id":"4b039e83159f81dc","repo":"jackwener/OpenCLI","slug":"label-returned-http-resp-status-4b039e","errorCode":null,"errorMessage":"${label} returned HTTP ${resp.status}","messagePattern":"(.+?) returned HTTP (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/wikidata/utils.js","lineNumber":82,"sourceCode":"        resp = await fetch(url, { headers: { 'user-agent': UA, accept: 'application/json' } });\n    }\n    catch (err) {\n        throw new CommandExecutionError(\n            `${label} request failed: ${err?.message ?? err}`,\n            'Check that www.wikidata.org is reachable from this network.',\n        );\n    }\n    if (resp.status === 404) {\n        throw new EmptyResultError(label, `Wikidata returned 404 for ${url}.`);\n    }\n    if (resp.status === 429) {\n        throw new CommandExecutionError(\n            `${label} returned HTTP 429 (rate limited)`,\n            'Wikidata throttles anonymous traffic; back off and retry.',\n        );\n    }\n    if (!resp.ok) {\n        throw new CommandExecutionError(`${label} returned HTTP ${resp.status}`);\n    }\n    let body;\n    try {\n        body = await resp.json();\n    }\n    catch (err) {\n        throw new CommandExecutionError(`${label} returned malformed JSON: ${err?.message ?? err}`);\n    }\n    return body;\n}\n\n/**\n * Pick a localised label / description from a `{<lang>: {value}}` map.\n * Falls back to English if the requested language is missing.\n */\nexport function pickLocalised(map, language) {\n    if (!map || typeof map !== 'object') return null;\n    const direct = map[language];","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/wikidata/utils.js#L64-L100","documentation":"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'.","triggerScenarios":"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.","commonSituations":"Wikidata service incidents (check wikitech status); corporate proxies or firewalls rewriting responses; making requests during known maintenance windows.","solutions":["Retry after a short delay — 5xx is usually transient","Check the Wikidata/Wikimedia status page for an ongoing incident","Log the full URL and status; verify the request is not being intercepted by a proxy or firewall","If status is 403, review your User-Agent and request volume against Wikimedia's User-Agent policy"],"exampleFix":"// before\nconst body = await wikidataFetch(url, 'search');\n// after\ntry {\n  const body = await wikidataFetch(url, 'search');\n} catch (err) {\n  if (/HTTP 5\\d\\d/.test(String(err.message))) {\n    await new Promise(r => setTimeout(r, 2000));\n    return retry(); // transient server error\n  }\n  throw err;\n}","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const body = await wikidataFetch(url, label);\n} catch (err) {\n  if (/HTTP [5]/.test(String(err.message))) {\n    await new Promise(r => setTimeout(r, 2000));\n    return wikidataFetch(url, label); // retry transient 5xx\n  }\n  throw err;\n}","preventionTips":["Retry 5xx responses with backoff — they are usually transient","Monitor the Wikimedia status page during incidents","Send a compliant, descriptive User-Agent","Check for corporate proxy interference when errors persist"],"tags":["http-error","wikidata","network","server-error"],"backgroundTag":"http-server-error","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}