{"record":{"id":"92a9b03863ee468c","repo":"jackwener/OpenCLI","slug":"zhihu-answer-detail-request-failed-http-status","errorCode":null,"errorMessage":"Zhihu answer detail request failed (HTTP ${status})","messagePattern":"Zhihu answer detail request failed \\(HTTP (.+?)\\)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/zhihu/answer-detail.js","lineNumber":99,"sourceCode":"        } catch (error) {\n          return { __malformedJson: error instanceof Error ? error.message : String(error) };\n        }\n      })()\n    `).catch((err) => {\n            throw new CommandExecutionError(\n                `Zhihu answer detail request failed: ${err instanceof Error ? err.message : String(err)}`,\n                'Try again later or rerun with -v for more detail.',\n            );\n        });\n        if (!data || data.__httpError) {\n            const status = data?.__httpError;\n            if (status === 401 || status === 403) {\n                throw new AuthRequiredError('www.zhihu.com', 'Failed to fetch Zhihu answer detail');\n            }\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        }","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/zhihu/answer-detail.js#L81-L117","documentation":"This CommandExecutionError is the fallback for the answer detail API responding with an unexpected HTTP status — any code other than 401/403/404 (and no network-level rejection). The status code is interpolated into the message so the developer can see exactly what Zhihu returned (e.g. 429 rate limit, 5xx server error).","triggerScenarios":"The in-page fetch returns __httpError set to a status like 429, 500, 502, or 503 from the Zhihu answer detail endpoint.","commonSituations":"Hitting Zhihu too frequently (429 rate limiting), Zhihu server-side incidents (5xx), or maintenance windows returning unusual statuses.","solutions":["Retry later or with backoff, especially if status is 429 or 5xx.","Rerun with -v for more detail about the request and response.","Reduce request frequency / add delays between calls to avoid rate limiting.","Check zhihu.com availability in a browser to rule out a site-wide outage."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":"function isHttpServerError(err) { const m = err?.message?.match(/HTTP (\\d{3})/); return !!m && Number(m[1]) >= 500 || (m && m[1] === '429'); }","tryCatchPattern":"try {\n  const detail = await answerDetail(id);\n} catch (err) {\n  const m = err.message.match(/HTTP (\\d{3})/);\n  if (m && (Number(m[1]) >= 500 || m[1] === '429')) {\n    return retryWithBackoff(() => answerDetail(id), { attempts: 5, baseMs: 2000 });\n  }\n  throw err;\n}","preventionTips":["Throttle request rate to avoid 429 responses.","Retry 5xx/429 with exponential backoff and jitter.","Monitor zhihu.com status during long-running scrapes.","Rerun with -v to confirm which status code was returned."],"tags":["http","http-5xx","rate-limit","zhihu"],"backgroundTag":"http-error-response","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}