jackwener/OpenCLI · error · CliError
PARSE_ERROR
PARSE_ERROR
Error message
Wikipedia trending returned an article without title
What it means
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.
Source
Thrown at clis/wikipedia/trending.js:31
{ 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
- 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
Example fix
// before opencli wikipedia trending --lang fr --limit 50 // after opencli wikipedia trending --lang en --limit 10
Defensive patterns
Strategy: retry
Type guard
function allTitlesValid(articles) {
return Array.isArray(articles) && articles.every(a => typeof a?.title === 'string' && a.title.trim().length > 0);
} Try / catch
try {
const rows = await run('wikipedia trending', ['--lang', lang, '--limit', String(limit)]);
} catch (e) {
if (e.code === 'PARSE_ERROR') {
return run('wikipedia trending', ['--lang', 'en', '--limit', String(limit)]);
}
throw e;
} Prevention
- 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
When it happens
Trigger: `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.
Common situations: Non-English editions with incomplete most-read metadata, feed glitches on a specific UTC date, schema drift in the REST featured feed.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- wikipedia returned malformed JSON: ${error?.message || error
- NOT_FOUND
- PARSE_ERROR
- Chess.com callback returned malformed JSON for ${url}: ${err
- Ctrip flight API returned invalid JSON
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/21f6d6f41ffa573b.
Report an issue: GitHub.