jackwener/OpenCLI · warning · EmptyResultError
${label} returned no articles.
Error message
${label} returned no articles. What it means
readDataArray in clis/juejin/utils.js:136 throws an EmptyResultError when `payload.data` is a valid but empty array. This is a distinct, catchable signal meaning the query succeeded but Juejin returned zero articles — the library forces callers to handle the empty case explicitly rather than silently producing no output.
Source
Thrown at clis/juejin/utils.js:136
}
if (!payload || typeof payload !== 'object' || Array.isArray(payload) || !Object.hasOwn(payload, 'err_no')) {
throw new CommandExecutionError(`${label} returned a malformed API envelope`);
}
if (payload.err_no !== 0) {
throw new CommandExecutionError(`${label} returned err_no ${payload.err_no}: ${payload.err_msg ?? ''}`);
}
return payload;
}
export function readDataArray(payload, label) {
if (!payload || typeof payload !== 'object' || Array.isArray(payload) || !Object.hasOwn(payload, 'data')) {
throw new CommandExecutionError(`${label} returned a malformed payload`);
}
if (!Array.isArray(payload.data)) {
throw new CommandExecutionError(`${label} returned a non-array data field`);
}
if (payload.data.length === 0) {
throw new EmptyResultError(label, `${label} returned no articles.`);
}
return payload.data;
}
function readArticleId(value, label) {
const id = String(value ?? '').trim();
if (!JUEJIN_ID.test(id)) {
throw new CommandExecutionError(`${label} returned a malformed article id`);
}
return id;
}
function readOptionalNumber(value, label) {
if (value == null) return null;
const n = Number(value);
if (!Number.isFinite(n)) {
throw new CommandExecutionError(`${label} returned a malformed numeric field`);
}View on GitHub (pinned to 49907e53dc)
Solutions
- Treat it as a normal empty result: catch EmptyResultError and print a friendly 'no articles found' message.
- If paginating, treat it as end-of-feed and stop requesting further cursors.
- Broaden the query — use a major category alias (frontend, backend, ai) or remove restrictive filters.
- Retry once after a short delay if emptiness is unexpected, to rule out a transient backend issue.
Example fix
// before
const rows = readDataArray(payload, 'juejin recommend');
// after
let rows;
try {
rows = readDataArray(payload, 'juejin recommend');
} catch (err) {
if (err instanceof EmptyResultError) { console.log('No articles found.'); return; }
throw err;
} Defensive patterns
Strategy: try-catch
Validate before calling
const data = payload?.data;
if (Array.isArray(data) && data.length === 0) {
console.log('No articles found for this query.');
return [];
} Type guard
function hasArticles(p) {
return Array.isArray(p?.data) && p.data.length > 0;
} Try / catch
try {
const rows = readDataArray(payload, 'juejin recommend');
render(rows);
} catch (err) {
if (err instanceof EmptyResultError) {
console.log('No articles found.');
return;
}
throw err;
} Prevention
- Always handle EmptyResultError separately from CommandExecutionError — it is a normal outcome.
- Stop paginating when you receive an empty page instead of requesting more cursors.
- Prefer broad category aliases over niche ids when a non-empty listing matters.
- Retry once on unexpectedly empty results to rule out transient backend gaps.
When it happens
Trigger: Any successful request whose `data` array has length 0: an obscure category with no articles, a cursor past the last page of a feed, a time-window or filter that matches nothing, or a hot list queried at a moment with no entries.
Common situations: Paging a recommend feed past its final cursor; querying a niche category slug; filtering by a tag that has no current articles; running the command during a Juejin data hiccup where the list is temporarily empty.
Understand the failure class
Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.
Related errors
- NO_DATA
- No recruiter-side chat sessions were returned.
- Boss returned no messages for this chat.
- coingecko exchanges
- Photo ID ${requestedPhotoId} was not found under subject ${s
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/8be2d84dba03bb27.
Report an issue: GitHub.