{"record":{"id":"d764c0356ceeb81a","repo":"jackwener/OpenCLI","slug":"zhihu-answer-detail-returned-a-malformed-payload","errorCode":null,"errorMessage":"Zhihu answer detail returned a malformed payload","messagePattern":"Zhihu answer detail returned a malformed payload","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/zhihu/answer-detail.js","lineNumber":113,"sourceCode":"            }\n            if (status === 404) {\n                throw new EmptyResultError('zhihu answer-detail', `No Zhihu answer was found for ${answerId}.`);\n            }\n            throw new CommandExecutionError(\n                status\n                    ? `Zhihu answer detail request failed (HTTP ${status})`\n                    : 'Zhihu answer detail request failed',\n                'Try again later or rerun with -v for more detail',\n            );\n        }\n        if (data.__malformedJson) {\n            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","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/zhihu/answer-detail.js#L95-L131","documentation":"This CommandExecutionError is thrown when the parsed response is valid JSON but is not a plain object — typeof data !== 'object' or Array.isArray(data). The library expects the Zhihu answer detail endpoint to return a JSON object; a scalar (string/number), null, or array indicates the response shape is not what the API contract promises.","triggerScenarios":"The endpoint returns valid JSON whose top-level value is null, an array, a string, or a number instead of an object (e.g. an array wrapper from an unexpected API version or a bare error string).","commonSituations":"Zhihu changed or versioned the API response shape, a proxy returned its own JSON error body (array of errors), or hitting a different endpoint that returns a list.","solutions":["Retry later; if Zhihu changed its API shape, update the CLI/library to a version matching the new contract.","Rerun with -v to capture the raw payload and confirm the unexpected shape.","Check for library/Zhihu API version drift and pin or upgrade accordingly."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":"function isPlainObject(v) { return typeof v === 'object' && v !== null && !Array.isArray(v); }","tryCatchPattern":"try {\n  const detail = await answerDetail(id);\n} catch (err) {\n  if (/malformed payload/.test(err.message)) {\n    console.error('Zhihu response shape changed — check for CLI/library updates.');\n    return null;\n  }\n  throw err;\n}","preventionTips":["Keep the CLI/library updated against Zhihu API shape changes.","Narrow the result with an isPlainObject guard in your own wrappers.","Log raw payloads (with -v) to detect contract drift early.","Pin a known-good CLI version if Zhihu changes its API mid-project."],"tags":["json","schema","api-contract","zhihu"],"backgroundTag":"unexpected-response-shape","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}