jackwener/OpenCLI · warning · EmptyResultError
频道 ${category} 返回空列表。
Error message
频道 ${category} 返回空列表。 What it means
This EmptyResultError is thrown by the toutiao recommend command when the upstream returned a valid array but no rows survived mapRecommendRow().filter(Boolean).slice(0, limit). Like the hot-board variant, an empty result after validation is treated as an explicit 'no data' outcome, reported with the requested channel (category) name.
Source
Thrown at clis/toutiao/recommend.js:68
}
if (!resp.ok) {
throw new CommandExecutionError(`toutiao recommend failed: HTTP ${resp.status}`);
}
let payload;
try {
payload = await resp.json();
} catch (error) {
throw new CommandExecutionError(`toutiao recommend returned malformed JSON: ${error?.message || error}`);
}
if (payload?.message && payload.message !== 'success') {
throw new CommandExecutionError(`toutiao recommend returned message=${payload.message}`);
}
if (!Array.isArray(payload?.data)) {
throw new CommandExecutionError('toutiao recommend returned a non-array data field');
}
const rows = payload.data.map(mapRecommendRow).filter(Boolean).slice(0, limit);
if (rows.length === 0) {
throw new EmptyResultError('toutiao recommend', `频道 ${category} 返回空列表。`);
}
// Re-rank (1..N) after filter so ranks are dense even if upstream had ads.
return rows.map((row, idx) => ({ ...row, rank: idx + 1 }));
},
});
View on GitHub (pinned to 49907e53dc)
Solutions
- Retry with a different or default category to confirm the issue is channel-specific.
- Verify the category slug is valid and currently supported by upstream.
- Log the raw payload.data entries; if they exist but all map to null, update mapRecommendRow for the changed schema.
- Handle EmptyResultError in calling code as a benign empty state rather than a crash.
Example fix
// before
const items = await recommend({ category: ' blockchain' });
// after
let items;
try { items = await recommend({ category: 'blockchain' }); }
catch (e) {
if (e instanceof EmptyResultError) items = [];
else throw e;
} Defensive patterns
Strategy: try-catch
Try / catch
try {
const items = await recommend({ category });
} catch (e) {
if (e instanceof EmptyResultError) {
console.warn(`No recommendations for this channel; try a default category.`);
return [];
}
throw e;
} Prevention
- Validate category slugs against a known-good list before calling.
- Fall back to a default category when one channel is empty.
- Treat empty results as data, not failure, in dashboards/aggregators.
- Investigate schema drift if every category starts returning empty.
When it happens
Trigger: Calling 'toutiao recommend --category <name>' where the channel returns an empty data array, or every row is dropped because mapRecommendRow returns null (missing required fields) or the limit slice yields nothing.
Common situations: Requesting a category that currently has no recommendations (niche/invalid category slug); upstream filtering out all items for the requester; schema change making mapRecommendRow return null for all rows.
Related errors
- 上游 hot-board 返回空列表。
- No prices returned for train_no=${trainNo} ${fromStation.nam
- No skills found.
- qwen history
- No 12306 stations match "${keyword}"
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/986ecaaa6d66aa59.
Report an issue: GitHub.