jackwener/OpenCLI · error · CommandExecutionError

Zhihu answer detail returned an error payload

Error message

Zhihu answer detail returned an error payload: ${data.error?.message || data.error_msg || data.message}

What it means

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.

Solutions

  1. Read the embedded Zhihu error message to identify the specific cause and act on it.
  2. Re-login or use an account with access to the requested answer if it is permission-related.
  3. Retry later if the message suggests a transient server-side condition.
  4. Rerun with -v for full payload context.
Defensive patterns

Strategy: try-catch

Type guard

function hasApiErrorField(d) { return !!(d && typeof d === 'object' && (d.error || d.error_msg || d.message)); }

Try / catch

try {
  const detail = await answerDetail(id);
} catch (err) {
  const m = err.message.match(/error payload: (.+)$/);
  if (m) {
    console.error(`Zhihu said: ${m[1]}`); // act on Zhihu's own message
    return null;
  }
  throw err;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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

Appendix: source

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

                    ? `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',
            );
        }
        if (data.error || data.error_msg || data.message) {
            throw new CommandExecutionError(
                `Zhihu answer detail returned an error payload: ${data.error?.message || data.error_msg || data.message}`,
                'Try again later or rerun with -v for more detail',
            );
        }
        if (!Object.prototype.hasOwnProperty.call(data, 'content')) {
            throw new CommandExecutionError(
                'Zhihu answer detail payload did not include answer content',
                'Try again later or rerun with -v for more detail',
            );
        }
        const question = data.question || {};
        // Answer ids and newer question ids can exceed
        // Number.MAX_SAFE_INTEGER. Prefer ids parsed from user input or
        // the canonical redirected URL; only fall back to API numeric ids
        // when no string-safe source is available.
        const questionId = target.questionId
            || currentQuestionId
            || extractQuestionIdFromAnswerUrl(question.url)

View on GitHub (pinned to 49907e53dc)