jackwener/OpenCLI · error · CliError
NOT_FOUND
NOT_FOUND
Error message
No random article returned
What it means
CliError with code NOT_FOUND thrown by `opencli wikipedia random` when the REST endpoint /api/rest_v1/page/random/summary returns a body without a title field. The random-summary endpoint normally always returns an article, so absence of a title indicates an unexpected/empty API response shape.
Source
Thrown at clis/wikipedia/random.js:17
import { CliError } from '@jackwener/opencli/errors';
import { cli, Strategy } from '@jackwener/opencli/registry';
import { formatSummaryRow, wikiFetch } from './utils.js';
cli({
site: 'wikipedia',
name: 'random',
access: 'read',
description: 'Get a random Wikipedia article',
strategy: Strategy.PUBLIC,
browser: false,
args: [{ name: 'lang', default: 'en', help: 'Language code (e.g. en, zh, ja)' }],
columns: ['title', 'description', 'extract', 'url'],
func: async (args) => {
const lang = args.lang || 'en';
const data = (await wikiFetch(lang, '/api/rest_v1/page/random/summary'));
if (!data?.title)
throw new CliError('NOT_FOUND', 'No random article returned', 'Try again');
return [formatSummaryRow(data, lang)];
},
});
View on GitHub (pinned to 49907e53dc)
Solutions
- Just retry — the endpoint is random and the failure is usually transient
- Try a different --lang (en is the most reliable)
- Check https://wikimediastatus.org for ongoing REST API incidents
- Update opencli in case the response schema changed
Example fix
// before opencli wikipedia random --lang cy // after opencli wikipedia random --lang en
Defensive patterns
Strategy: retry
Type guard
function isRandomSummary(d) {
return !!d && typeof d === 'object' && typeof d.title === 'string' && d.title.length > 0;
} Try / catch
try {
const rows = await run('wikipedia random', ['--lang', lang]);
} catch (e) {
if (e.code === 'NOT_FOUND') {
await sleep(1000);
return run('wikipedia random', ['--lang', 'en']);
}
throw e;
} Prevention
- Retry immediately — random endpoint failures are transient
- Default to --lang en for the most reliable REST API
- Watch Wikimedia status for REST incidents
When it happens
Trigger: Calling `opencli wikipedia random --lang <lang>` where wikiFetch's JSON lacks data.title — e.g. the REST API returning an empty object, a non-standard redirect body, or a language edition whose REST API misbehaves.
Common situations: Less-maintained language editions with broken REST endpoints, transient upstream API incidents, or an API schema change removing/renaming the title field in the random summary response.
Understand the failure class
Background: NOT_FOUND error code: why tRPC, Harbor, Nacos and other libraries return 404 "not found" errors for resources that may still exist — this error's family across 11 libraries.
Related errors
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/c98e726261584e8f.
Report an issue: GitHub.