{"record":{"id":"c98e726261584e8f","repo":"jackwener/OpenCLI","slug":"not-found-c98e72","errorCode":"NOT_FOUND","errorMessage":"No random article returned","messagePattern":"No random article returned","errorType":"error_code","errorClass":"CliError","httpStatus":null,"severity":"error","filePath":"clis/wikipedia/random.js","lineNumber":17,"sourceCode":"import { CliError } from '@jackwener/opencli/errors';\nimport { cli, Strategy } from '@jackwener/opencli/registry';\nimport { formatSummaryRow, wikiFetch } from './utils.js';\ncli({\n    site: 'wikipedia',\n    name: 'random',\n    access: 'read',\n    description: 'Get a random Wikipedia article',\n    strategy: Strategy.PUBLIC,\n    browser: false,\n    args: [{ name: 'lang', default: 'en', help: 'Language code (e.g. en, zh, ja)' }],\n    columns: ['title', 'description', 'extract', 'url'],\n    func: async (args) => {\n        const lang = args.lang || 'en';\n        const data = (await wikiFetch(lang, '/api/rest_v1/page/random/summary'));\n        if (!data?.title)\n            throw new CliError('NOT_FOUND', 'No random article returned', 'Try again');\n        return [formatSummaryRow(data, lang)];\n    },\n});\n","sourceCodeStart":1,"sourceCodeEnd":21,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/wikipedia/random.js#L1-L21","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nopencli wikipedia random --lang cy\n// after\nopencli wikipedia random --lang en","handlingStrategy":"retry","validationCode":null,"typeGuard":"function isRandomSummary(d) {\n  return !!d && typeof d === 'object' && typeof d.title === 'string' && d.title.length > 0;\n}","tryCatchPattern":"try {\n  const rows = await run('wikipedia random', ['--lang', lang]);\n} catch (e) {\n  if (e.code === 'NOT_FOUND') {\n    await sleep(1000);\n    return run('wikipedia random', ['--lang', 'en']);\n  }\n  throw e;\n}","preventionTips":["Retry immediately — random endpoint failures are transient","Default to --lang en for the most reliable REST API","Watch Wikimedia status for REST incidents"],"tags":["not-found","wikipedia","rest-api"],"backgroundTag":"not-found","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}