{"record":{"id":"7892f7dc8584cbc3","repo":"jackwener/OpenCLI","slug":"not-found-7892f7","errorCode":"NOT_FOUND","errorMessage":"No trending articles available","messagePattern":"No trending articles available","errorType":"error_code","errorClass":"CliError","httpStatus":null,"severity":"error","filePath":"clis/wikipedia/trending.js","lineNumber":28,"sourceCode":"    browser: false,\n    args: [\n        { name: 'limit', type: 'int', default: 10, help: 'Max results' },\n        { 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":10,"sourceCodeEnd":41,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/wikipedia/trending.js#L10-L41","documentation":"CliError with code NOT_FOUND thrown by `opencli wikipedia trending` when the featured-feed endpoint /api/rest_v1/feed/featured/<yyyy>/<mm>/<dd> returns no mostread.articles array. The trending feed needs a non-empty most-read list for the UTC date to produce ranked output.","triggerScenarios":"Calling `opencli wikipedia trending --lang <lang>` where data.mostread.articles is absent or empty — language editions that don't publish the most-read feed, dates before the feed existed, or REST API returning a partial featured payload.","commonSituations":"Small/less-supported language editions lacking most-read data, transient Wikimedia REST API gaps, requesting a --date far in the past on a wiki without historical feed data.","solutions":["Try --lang en, which has the most complete feed coverage","Retry later if it's a transient API gap","Omit a custom date or pick a recent UTC date where the feed exists","Check the endpoint manually: https://en.wikipedia.org/api/rest_v1/feed/featured/<y>/<m>/<d>"],"exampleFix":"// before\nopencli wikipedia trending --lang nah\n// after\nopencli wikipedia trending --lang en","handlingStrategy":"fallback","validationCode":null,"typeGuard":"function hasMostRead(d) {\n  return Array.isArray(d?.mostread?.articles) && d.mostread.articles.length > 0;\n}","tryCatchPattern":"try {\n  const rows = await run('wikipedia trending', ['--lang', lang]);\n} catch (e) {\n  if (e.code === 'NOT_FOUND') {\n    return run('wikipedia trending', ['--lang', 'en']);\n  }\n  throw e;\n}","preventionTips":["Prefer --lang en which always publishes the most-read feed","Retry later for transient feed gaps","Verify feed data manually via the REST URL before scripting"],"tags":["not-found","wikipedia","trending"],"backgroundTag":"not-found","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}