jackwener/OpenCLI · error · CommandExecutionError
Zhihu answer detail payload did not include answer content
Error message
Zhihu answer detail payload did not include answer content
What it means
This CommandExecutionError is thrown when the response object is otherwise valid but lacks a `content` property, verified with Object.prototype.hasOwnProperty.call(data, 'content'). The library requires the answer body field to be present (even if empty); its absence means the payload does not contain the answer content the command exists to extract.
Source
Thrown at clis/zhihu/answer-detail.js:125
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',
);
}
if (data.error || data.error_msg || data.message) {
throw new CommandExecutionError(
`Zhihu answer detail returned an error payload: ${data.error?.message || data.error_msg || data.message}`,
'Try again later or rerun with -v for more detail',
);
}
if (!Object.prototype.hasOwnProperty.call(data, 'content')) {
throw new CommandExecutionError(
'Zhihu answer detail payload did not include answer content',
'Try again later or rerun with -v for more detail',
);
}
const question = data.question || {};
// Answer ids and newer question ids can exceed
// Number.MAX_SAFE_INTEGER. Prefer ids parsed from user input or
// the canonical redirected URL; only fall back to API numeric ids
// when no string-safe source is available.
const questionId = target.questionId
|| currentQuestionId
|| extractQuestionIdFromAnswerUrl(question.url)
|| (question.id == null ? '' : String(question.id));
const stripped = stripHtml(data.content || '');
// Truncation is opt-in only; default `maxContent === 0` short-
// circuits the conditional so the full stripped body is returned.
const content = maxContent > 0 && stripped.length > maxContent
? stripped.substring(0, maxContent)View on GitHub (pinned to 49907e53dc)
Solutions
- Retry later or rerun with -v to inspect the payload and confirm which fields Zhihu returned.
- Update the CLI/library if Zhihu changed the payload schema (missing `content` in newer responses).
- Try the browser page directly for that answer to see if the content is accessible at all.
- Treat restricted/paywalled answers as unsupported and skip them in bulk workflows.
Defensive patterns
Strategy: type-guard
Type guard
function hasContentField(d) { return !!d && typeof d === 'object' && Object.prototype.hasOwnProperty.call(d, 'content'); } Try / catch
try {
const detail = await answerDetail(id);
} catch (err) {
if (/did not include answer content/.test(err.message)) {
console.warn('Payload missing content — answer may be restricted or schema changed.');
return null;
}
throw err;
} Prevention
- Guard your own parsing with a hasOwnProperty('content') check.
- Update the CLI if Zhihu renamed/moved the content field.
- Treat missing-content answers as restricted and exclude them from workflows.
- Use -v logging to capture the actual returned fields when this occurs.
When it happens
Trigger: The fetched JSON object passes all earlier checks (object, no error fields) but has no own 'content' key — e.g. Zhihu returned a partial/teaser payload or a differently shaped object for this answer.
Common situations: Zhihu A/B API changes omitting `content` for some answers, responses for paywalled/restricted answers lacking the field, or an API version mismatch between the CLI and Zhihu's current payload schema.
Related errors
- Zhihu answer detail returned a malformed payload
- ${label} did not include a stable ${field}.
- Flomo API returned a memo without slug/id
- toutiao recommend returned a non-array data field
- WeRead search API returned an unreadable books payload
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/fbc54bab3b3c23c2.
Report an issue: GitHub.