{"record":{"id":"0bad9110cd729d9e","repo":"jackwener/OpenCLI","slug":"wikipedia-page-failed-http-resp-status","errorCode":null,"errorMessage":"wikipedia page failed: HTTP ${resp.status}","messagePattern":"wikipedia page failed: HTTP (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/wikipedia/page.js","lineNumber":63,"sourceCode":"        url.searchParams.set('prop', 'extracts|info|description');\n        url.searchParams.set('inprop', 'url');\n        url.searchParams.set('explaintext', '1');\n        url.searchParams.set('redirects', '1');\n        url.searchParams.set('titles', title);\n\n        let resp;\n        try {\n            resp = await fetch(url, {\n                headers: {\n                    'User-Agent': 'opencli/1.0 (+https://github.com/jackwener/opencli)',\n                    'Accept': 'application/json',\n                },\n            });\n        } catch (error) {\n            throw new CommandExecutionError(`wikipedia page request failed: ${error?.message || error}`);\n        }\n        if (!resp.ok) {\n            throw new CommandExecutionError(`wikipedia page failed: HTTP ${resp.status}`);\n        }\n        let data;\n        try {\n            data = await resp.json();\n        } catch (error) {\n            throw new CommandExecutionError(`wikipedia returned malformed JSON: ${error?.message || error}`);\n        }\n        if (data?.error) {\n            throw new CommandExecutionError(`wikipedia API error: ${data.error.info || data.error.code}`);\n        }\n        const pages = Array.isArray(data?.query?.pages) ? data.query.pages : [];\n        const page = pages[0];\n        if (!page || page.missing) {\n            throw new EmptyResultError('wikipedia page', `No article \"${title}\" on ${lang}.wikipedia.org. Try \\`opencli wikipedia search\\` first.`);\n        }\n        const fullExtract = String(page.extract ?? '');\n        if (!fullExtract.trim()) {\n            throw new EmptyResultError('wikipedia page', `Article \"${page.title}\" exists but has no plain-text extract (likely a disambiguation/redirect page).`);","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/wikipedia/page.js#L45-L81","documentation":"When the Wikipedia API responds with a non-OK HTTP status (404, 403, 5xx, etc.), page.js throws a CommandExecutionError with the raw status code. Unlike the wikidata helper, this command does not special-case 404 — a missing article is normally reported via the API body (data.error / page.missing), so an HTTP-level failure usually indicates an infrastructure or filtering problem.","triggerScenarios":"Wikipedia edge returning 403 for blocked/proxy traffic or non-compliant User-Agent; 5xx during Wikimedia outages; 429 after hammering the API from one IP; requests blocked by a corporate firewall producing gateway error statuses.","commonSituations":"High-volume scraping from CI IPs hitting Wikimedia rate limits/abuse filters; Wikimedia maintenance windows; VPN/proxy exits flagged by Wikimedia.","solutions":["Retry after a delay if the status is 429 or 5xx (transient)","Check the Wikimedia status page for incidents","Review request volume; add throttling/caching and a descriptive User-Agent","Test the same api.php URL in a browser/curl to see if the block is environment-specific"],"exampleFix":"// before\nawait Promise.all(titles.map(t => fetchPage(t))); // bursts trigger 429/403\n// after\nfor (const t of titles) {\n  await fetchPage(t);\n  await new Promise(r => setTimeout(r, 300));\n}","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"const fetchWithRetry = async (args, retries = 3) => {\n  for (let i = 0; ; i++) {\n    try { return await pageCommand(args); }\n    catch (err) {\n      const m = /HTTP (\\d+)/.exec(String(err.message));\n      const s = m && Number(m[1]);\n      if ((!s || !(s === 429 || s >= 500)) || i >= retries) throw err;\n      await new Promise(r => setTimeout(r, 1000 * 2 ** i));\n    }\n  }\n};","preventionTips":["Throttle request rate and cache results","Send a descriptive User-Agent per Wikimedia policy","Watch the Wikimedia status page for incidents","Rotate exit IPs / avoid flagged VPN ranges for bulk jobs"],"tags":["http-error","wikipedia","network","rate-limit"],"backgroundTag":"http-server-error","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}