jackwener/OpenCLI · error · CommandExecutionError

Zhihu answer detail request failed

Error message

Zhihu answer detail request failed (HTTP ${status})

What it means

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).

Solutions

  1. Retry later or with backoff, especially if status is 429 or 5xx.
  2. Rerun with -v for more detail about the request and response.
  3. Reduce request frequency / add delays between calls to avoid rate limiting.
  4. Check zhihu.com availability in a browser to rule out a site-wide outage.
Defensive patterns

Strategy: retry

Type guard

function isHttpServerError(err) { const m = err?.message?.match(/HTTP (\d{3})/); return !!m && Number(m[1]) >= 500 || (m && m[1] === '429'); }

Try / catch

try {
  const detail = await answerDetail(id);
} catch (err) {
  const m = err.message.match(/HTTP (\d{3})/);
  if (m && (Number(m[1]) >= 500 || m[1] === '429')) {
    return retryWithBackoff(() => answerDetail(id), { attempts: 5, baseMs: 2000 });
  }
  throw err;
}

Prevention

When it happens

Trigger: The in-page fetch returns __httpError set to a status like 429, 500, 502, or 503 from the Zhihu answer detail endpoint.

Common situations: Hitting Zhihu too frequently (429 rate limiting), Zhihu server-side incidents (5xx), or maintenance windows returning unusual statuses.

Understand the failure class

Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/92a9b03863ee468c. Report an issue: GitHub.

Appendix: source

Thrown at clis/zhihu/answer-detail.js:99

        } catch (error) {
          return { __malformedJson: error instanceof Error ? error.message : String(error) };
        }
      })()
    `).catch((err) => {
            throw new CommandExecutionError(
                `Zhihu answer detail request failed: ${err instanceof Error ? err.message : String(err)}`,
                'Try again later or rerun with -v for more detail.',
            );
        });
        if (!data || data.__httpError) {
            const status = data?.__httpError;
            if (status === 401 || status === 403) {
                throw new AuthRequiredError('www.zhihu.com', 'Failed to fetch Zhihu answer detail');
            }
            if (status === 404) {
                throw new EmptyResultError('zhihu answer-detail', `No Zhihu answer was found for ${answerId}.`);
            }
            throw new CommandExecutionError(
                status
                    ? `Zhihu answer detail request failed (HTTP ${status})`
                    : 'Zhihu answer detail request failed',
                'Try again later or rerun with -v for more detail',
            );
        }
        if (data.__malformedJson) {
            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',
            );
        }

View on GitHub (pinned to 49907e53dc)