{"record":{"id":"fbc54bab3b3c23c2","repo":"jackwener/OpenCLI","slug":"zhihu-answer-detail-payload-did-not-include-answer","errorCode":null,"errorMessage":"Zhihu answer detail payload did not include answer content","messagePattern":"Zhihu answer detail payload did not include answer content","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/zhihu/answer-detail.js","lineNumber":125,"sourceCode":"            throw new CommandExecutionError(\n                `Zhihu answer detail returned malformed JSON: ${data.__malformedJson}`,\n                'Try again later or rerun with -v for more detail',\n            );\n        }\n        if (typeof data !== 'object' || Array.isArray(data)) {\n            throw new CommandExecutionError(\n                'Zhihu answer detail returned a malformed payload',\n                'Try again later or rerun with -v for more detail',\n            );\n        }\n        if (data.error || data.error_msg || data.message) {\n            throw new CommandExecutionError(\n                `Zhihu answer detail returned an error payload: ${data.error?.message || data.error_msg || data.message}`,\n                'Try again later or rerun with -v for more detail',\n            );\n        }\n        if (!Object.prototype.hasOwnProperty.call(data, 'content')) {\n            throw new CommandExecutionError(\n                'Zhihu answer detail payload did not include answer content',\n                'Try again later or rerun with -v for more detail',\n            );\n        }\n        const question = data.question || {};\n        // Answer ids and newer question ids can exceed\n        // Number.MAX_SAFE_INTEGER. Prefer ids parsed from user input or\n        // the canonical redirected URL; only fall back to API numeric ids\n        // when no string-safe source is available.\n        const questionId = target.questionId\n            || currentQuestionId\n            || extractQuestionIdFromAnswerUrl(question.url)\n            || (question.id == null ? '' : String(question.id));\n        const stripped = stripHtml(data.content || '');\n        // Truncation is opt-in only; default `maxContent === 0` short-\n        // circuits the conditional so the full stripped body is returned.\n        const content = maxContent > 0 && stripped.length > maxContent\n            ? stripped.substring(0, maxContent)","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/zhihu/answer-detail.js#L107-L143","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":"function hasContentField(d) { return !!d && typeof d === 'object' && Object.prototype.hasOwnProperty.call(d, 'content'); }","tryCatchPattern":"try {\n  const detail = await answerDetail(id);\n} catch (err) {\n  if (/did not include answer content/.test(err.message)) {\n    console.warn('Payload missing content — answer may be restricted or schema changed.');\n    return null;\n  }\n  throw err;\n}","preventionTips":["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."],"tags":["schema","missing-field","api-contract","zhihu"],"backgroundTag":"missing-response-field","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}