jackwener/OpenCLI · error · CommandExecutionError
wikipedia page failed: HTTP ${resp.status}
Error message
wikipedia page failed: HTTP ${resp.status} What it means
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.
Source
Thrown at clis/wikipedia/page.js:63
url.searchParams.set('prop', 'extracts|info|description');
url.searchParams.set('inprop', 'url');
url.searchParams.set('explaintext', '1');
url.searchParams.set('redirects', '1');
url.searchParams.set('titles', title);
let resp;
try {
resp = await fetch(url, {
headers: {
'User-Agent': 'opencli/1.0 (+https://github.com/jackwener/opencli)',
'Accept': 'application/json',
},
});
} catch (error) {
throw new CommandExecutionError(`wikipedia page request failed: ${error?.message || error}`);
}
if (!resp.ok) {
throw new CommandExecutionError(`wikipedia page failed: HTTP ${resp.status}`);
}
let data;
try {
data = await resp.json();
} catch (error) {
throw new CommandExecutionError(`wikipedia returned malformed JSON: ${error?.message || error}`);
}
if (data?.error) {
throw new CommandExecutionError(`wikipedia API error: ${data.error.info || data.error.code}`);
}
const pages = Array.isArray(data?.query?.pages) ? data.query.pages : [];
const page = pages[0];
if (!page || page.missing) {
throw new EmptyResultError('wikipedia page', `No article "${title}" on ${lang}.wikipedia.org. Try \`opencli wikipedia search\` first.`);
}
const fullExtract = String(page.extract ?? '');
if (!fullExtract.trim()) {
throw new EmptyResultError('wikipedia page', `Article "${page.title}" exists but has no plain-text extract (likely a disambiguation/redirect page).`);View on GitHub (pinned to 49907e53dc)
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
Example fix
// before
await Promise.all(titles.map(t => fetchPage(t))); // bursts trigger 429/403
// after
for (const t of titles) {
await fetchPage(t);
await new Promise(r => setTimeout(r, 300));
} Defensive patterns
Strategy: retry
Try / catch
const fetchWithRetry = async (args, retries = 3) => {
for (let i = 0; ; i++) {
try { return await pageCommand(args); }
catch (err) {
const m = /HTTP (\d+)/.exec(String(err.message));
const s = m && Number(m[1]);
if ((!s || !(s === 429 || s >= 500)) || i >= retries) throw err;
await new Promise(r => setTimeout(r, 1000 * 2 ** i));
}
}
}; Prevention
- 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
When it happens
Trigger: 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.
Common situations: High-volume scraping from CI IPs hitting Wikimedia rate limits/abuse filters; Wikimedia maintenance windows; VPN/proxy exits flagged by Wikimedia.
Related errors
- Flomo API returned HTTP ${resp.status}
- ${label} failed: HTTP ${response.status}
- Sales Navigator lead search API returned an unexpected respo
- lobsters domain returned HTTP ${resp.status}
- HTTP ${probe.httpStatus} from nowcoder profile API
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/0bad9110cd729d9e.
Report an issue: GitHub.