jackwener/OpenCLI · warning · EmptyResultError
zhihu answer-detail
zhihu answer-detail
Error message
No Zhihu answer was found for ${answerId}. What it means
This EmptyResultError (code 'zhihu answer-detail') is thrown when the Zhihu answer detail API responds with HTTP 404, meaning no answer exists for the given answer id. It is a deliberate 'nothing found' signal rather than a failure, letting callers treat unknown ids as empty results.
Source
Thrown at clis/zhihu/answer-detail.js:97
try {
return await r.json();
} catch (error) {
return { __malformedJson: error instanceof Error ? error.message : String(error) };
}
})()
`).catch((err) => {
throw new CommandExecutionError(
`Zhihu answer detail request failed: ${err instanceof Error ? err.message : String(err)}`,
'Try again later or rerun with -v for more detail.',
);
});
if (!data || data.__httpError) {
const status = data?.__httpError;
if (status === 401 || status === 403) {
throw new AuthRequiredError('www.zhihu.com', 'Failed to fetch Zhihu answer detail');
}
if (status === 404) {
throw new EmptyResultError('zhihu answer-detail', `No Zhihu answer was found for ${answerId}.`);
}
throw new CommandExecutionError(
status
? `Zhihu answer detail request failed (HTTP ${status})`
: 'Zhihu answer detail request failed',
'Try again later or rerun with -v for more detail',
);
}
if (data.__malformedJson) {
throw new CommandExecutionError(
`Zhihu answer detail returned malformed JSON: ${data.__malformedJson}`,
'Try again later or rerun with -v for more detail',
);
}
if (typeof data !== 'object' || Array.isArray(data)) {
throw new CommandExecutionError(
'Zhihu answer detail returned a malformed payload',
'Try again later or rerun with -v for more detail',View on GitHub (pinned to 49907e53dc)
Solutions
- Double-check the answer id — open https://www.zhihu.com/answer/<id> in a browser to confirm it exists.
- Copy the full answer URL and re-extract the id from /answer/<aid> instead of retyping it.
- If the answer was deleted, no fix is possible; handle the empty result in your script.
Example fix
// before clis zhihu answer-detail 19012345 // typo'd id -> 404 // after clis zhihu answer-detail 6190123456789012345 // id verified against the live URL
Defensive patterns
Strategy: validation
Validate before calling
// validate the id format before calling
if (!/^\d{10,20}$/.test(String(answerId))) throw new Error(`Suspicious answer id: ${answerId}`); Type guard
function isEmptyResultError(err) { return err instanceof EmptyResultError || err?.code === 'zhihu answer-detail'; } Try / catch
try {
const detail = await answerDetail(id);
} catch (err) {
if (err instanceof EmptyResultError) {
console.warn(`Answer ${id} not found — skipping`);
return null;
}
throw err;
} Prevention
- Extract answer ids programmatically from full URLs instead of retyping them.
- Treat EmptyResultError as a skip condition in bulk scripts.
- Check the answer still exists in a browser before deep workflows.
- Record not-found ids to avoid repeatedly querying deleted content.
When it happens
Trigger: The in-page fetch returns __httpError === 404: the answerId passed on the command line does not correspond to any existing Zhihu answer (deleted answer, wrong id, or truncated/typo'd id).
Common situations: Answer was deleted by its author or removed by Zhihu moderation, id copied from an incomplete URL, digits transposed when typing the id, or scraping a very old answer that has since been purged.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Chess.com returned 404 for ${url}
- crates.io returned 404 for ${url}.
- Maven Central returned 404 for ${url}.
- bilibili creator-stats ${bvid}
- coingecko has no coin with id "${id}".
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/e85ec21950e93117.
Report an issue: GitHub.