jackwener/OpenCLI · error · CliError
NOT_FOUND
NOT_FOUND
Error message
No trending articles available
What it means
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.
Source
Thrown at clis/wikipedia/trending.js:28
browser: false,
args: [
{ name: 'limit', type: 'int', default: 10, help: 'Max results' },
{ name: 'lang', default: 'en', help: 'Language code (e.g. en, zh, ja)' },
],
columns: ['rank', 'title', 'description', 'views'],
func: async (args) => {
const lang = args.lang || 'en';
const limit = Math.max(1, Math.min(Number(args.limit), 50));
// Use yesterday's UTC date — Wikipedia API expects UTC and yesterday
// guarantees data availability (today's aggregation may be incomplete).
const d = new Date(Date.now() - 86_400_000);
const yyyy = d.getUTCFullYear();
const mm = String(d.getUTCMonth() + 1).padStart(2, '0');
const dd = String(d.getUTCDate()).padStart(2, '0');
const data = (await wikiFetch(lang, `/api/rest_v1/feed/featured/${yyyy}/${mm}/${dd}`));
const articles = data?.mostread?.articles;
if (!articles?.length)
throw new CliError('NOT_FOUND', 'No trending articles available', 'Try a different language with --lang');
const selectedArticles = articles.slice(0, limit);
if (selectedArticles.some((article) => !String(article?.title || '').trim())) {
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.');
}
return selectedArticles.map((a, i) => ({
rank: i + 1,
title: a.title,
description: (a.description ?? '').slice(0, DESC_MAX_LEN),
views: a.views ?? 0,
}));
},
});
View on GitHub (pinned to 49907e53dc)
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>
Example fix
// before opencli wikipedia trending --lang nah // after opencli wikipedia trending --lang en
Defensive patterns
Strategy: fallback
Type guard
function hasMostRead(d) {
return Array.isArray(d?.mostread?.articles) && d.mostread.articles.length > 0;
} Try / catch
try {
const rows = await run('wikipedia trending', ['--lang', lang]);
} catch (e) {
if (e.code === 'NOT_FOUND') {
return run('wikipedia trending', ['--lang', 'en']);
}
throw e;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
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/7892f7dc8584cbc3.
Report an issue: GitHub.