{"record":{"id":"0a59e682bf7de1f5","repo":"jackwener/OpenCLI","slug":"zhihu-answer-detail-returned-an-error-payload-d","errorCode":null,"errorMessage":"Zhihu answer detail returned an error payload: ${data.error?.message || data.error_msg || data.message}","messagePattern":"Zhihu answer detail returned an error payload: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/zhihu/answer-detail.js","lineNumber":119,"sourceCode":"                    ? `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\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)","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/zhihu/answer-detail.js#L101-L137","documentation":"This CommandExecutionError is thrown when the response object explicitly signals an application-level error: it contains an `error` object, `error_msg`, or `message` field. The first available message (data.error?.message, else data.error_msg, else data.message) is embedded in the thrown error, surfacing Zhihu's own error text to the developer.","triggerScenarios":"The fetched JSON object has a truthy data.error, data.error_msg, or data.message — Zhihu processed the request but returned an API-level error (e.g. account restriction, content removed, permission denial) with HTTP 200.","commonSituations":"Answer content restricted by Zhihu policy, account-level API limits, session recognized but not authorized for that content, or Zhihu soft-error responses that still use HTTP 200.","solutions":["Read the embedded Zhihu error message to identify the specific cause and act on it.","Re-login or use an account with access to the requested answer if it is permission-related.","Retry later if the message suggests a transient server-side condition.","Rerun with -v for full payload context."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function hasApiErrorField(d) { return !!(d && typeof d === 'object' && (d.error || d.error_msg || d.message)); }","tryCatchPattern":"try {\n  const detail = await answerDetail(id);\n} catch (err) {\n  const m = err.message.match(/error payload: (.+)$/);\n  if (m) {\n    console.error(`Zhihu said: ${m[1]}`); // act on Zhihu's own message\n    return null;\n  }\n  throw err;\n}","preventionTips":["Parse and log the embedded Zhihu message to distinguish permission vs. transient issues.","Re-login when messages indicate session or permission problems.","Skip answers whose error messages indicate policy restriction instead of retrying.","Back off when messages suggest server-side load."],"tags":["api-error","zhihu","payload"],"backgroundTag":"api-error-payload","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}