{"record":{"id":"21f6d6f41ffa573b","repo":"jackwener/OpenCLI","slug":"parse-error-21f6d6","errorCode":"PARSE_ERROR","errorMessage":"Wikipedia trending returned an article without title","messagePattern":"Wikipedia trending returned an article without title","errorType":"error_code","errorClass":"CliError","httpStatus":null,"severity":"error","filePath":"clis/wikipedia/trending.js","lineNumber":31,"sourceCode":"        { name: 'lang', default: 'en', help: 'Language code (e.g. en, zh, ja)' },\n    ],\n    columns: ['rank', 'title', 'description', 'views'],\n    func: async (args) => {\n        const lang = args.lang || 'en';\n        const limit = Math.max(1, Math.min(Number(args.limit), 50));\n        // Use yesterday's UTC date — Wikipedia API expects UTC and yesterday\n        // guarantees data availability (today's aggregation may be incomplete).\n        const d = new Date(Date.now() - 86_400_000);\n        const yyyy = d.getUTCFullYear();\n        const mm = String(d.getUTCMonth() + 1).padStart(2, '0');\n        const dd = String(d.getUTCDate()).padStart(2, '0');\n        const data = (await wikiFetch(lang, `/api/rest_v1/feed/featured/${yyyy}/${mm}/${dd}`));\n        const articles = data?.mostread?.articles;\n        if (!articles?.length)\n            throw new CliError('NOT_FOUND', 'No trending articles available', 'Try a different language with --lang');\n        const selectedArticles = articles.slice(0, limit);\n        if (selectedArticles.some((article) => !String(article?.title || '').trim())) {\n            throw new CliError('PARSE_ERROR', 'Wikipedia trending returned an article without title', 'Trending rows require a title so they can be opened with wikipedia page.');\n        }\n        return selectedArticles.map((a, i) => ({\n            rank: i + 1,\n            title: a.title,\n            description: (a.description ?? '').slice(0, DESC_MAX_LEN),\n            views: a.views ?? 0,\n        }));\n    },\n});\n","sourceCodeStart":13,"sourceCodeEnd":41,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/wikipedia/trending.js#L13-L41","documentation":"CliError with code PARSE_ERROR thrown by `opencli wikipedia trending` when one of the selected most-read articles lacks a non-blank title. Rows must carry a title because they're meant to be opened with `wikipedia page`, so the command fails fast instead of emitting an unopenable row.","triggerScenarios":"`opencli wikipedia trending` where any of the first `limit` entries in data.mostread.articles has article.title missing, null, or whitespace-only — upstream feed data quality issues on certain wikis/dates.","commonSituations":"Non-English editions with incomplete most-read metadata, feed glitches on a specific UTC date, schema drift in the REST featured feed.","solutions":["Retry on a different date (omit --date) to get a clean feed","Switch to --lang en for the best-maintained feed data","Lower --limit so fewer articles are selected (may still hit a bad one, but often avoids it)","Inspect the raw feed JSON to confirm which entry lacks a title, and report/update opencli"],"exampleFix":"// before\nopencli wikipedia trending --lang fr --limit 50\n// after\nopencli wikipedia trending --lang en --limit 10","handlingStrategy":"retry","validationCode":null,"typeGuard":"function allTitlesValid(articles) {\n  return Array.isArray(articles) && articles.every(a => typeof a?.title === 'string' && a.title.trim().length > 0);\n}","tryCatchPattern":"try {\n  const rows = await run('wikipedia trending', ['--lang', lang, '--limit', String(limit)]);\n} catch (e) {\n  if (e.code === 'PARSE_ERROR') {\n    return run('wikipedia trending', ['--lang', 'en', '--limit', String(limit)]);\n  }\n  throw e;\n}","preventionTips":["Retry with a different date or language","Use --lang en for the cleanest feed metadata","Keep --limit modest to reduce odds of selecting bad rows"],"tags":["parse-error","wikipedia","trending"],"backgroundTag":"schema-validation-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}