jackwener/OpenCLI · error · CommandExecutionError

Zhihu ${label} returned an error payload: ${payload.__errorM

Error message

Zhihu ${label} returned an error payload: ${payload.__errorMessage || code}

What it means

CommandExecutionError raised when Zhihu returned an error payload that carried no HTTP failure status but did include an error indication (__errorMessage or __errorCode) not covered by the special cases. The message surfaces Zhihu's own error text or code so the developer can see why the API refused the logical request.

Source

Thrown at clis/zhihu/answer-comments-helpers.js:79

    }
    if (!payload || typeof payload !== 'object' || Array.isArray(payload)) {
        throw new CommandExecutionError(`Zhihu ${label} returned a malformed payload`);
    }
    const status = payload.__httpStatus;
    const code = String(payload.__errorCode || '');
    if (status >= 400 || code || payload.__errorMessage || payload.__needLogin) {
        if (code === '40362') {
            throw new CommandExecutionError(
                `Zhihu risk control blocked ${label} (40362): ${payload.__errorMessage || 'abnormal request'}`,
                'Open the answer in the connected Chrome profile and retry later.',
            );
        }
        if (status === 401 || status === 403 || code === '40353' || payload.__needLogin) {
            throw new AuthRequiredError('www.zhihu.com', `Failed to fetch Zhihu ${label}`);
        }
        if (status === 404 && notFoundDetail) throw new EmptyResultError('zhihu answer-comments', notFoundDetail);
        if (status >= 400) throw new CommandExecutionError(`Zhihu ${label} request failed (HTTP ${status})`);
        throw new CommandExecutionError(`Zhihu ${label} returned an error payload: ${payload.__errorMessage || code}`);
    }
    if (!Array.isArray(payload.data) || !payload.paging || typeof payload.paging !== 'object') {
        throw new CommandExecutionError(`Zhihu ${label} returned a malformed payload`);
    }
    if (typeof payload.paging.is_end !== 'boolean') {
        throw new CommandExecutionError(`Zhihu ${label} returned malformed paging state`);
    }
    return payload;
}
function describeComment(comment, role, expectedRootId = '') {
    if (!comment || typeof comment !== 'object' || Array.isArray(comment)) {
        throw new CommandExecutionError(`Zhihu answer comments contained a malformed ${role} row`);
    }
    const id = commentId(comment.id);
    if (!id) throw new CommandExecutionError(`Zhihu answer comments contained a ${role} row without a stable id`);
    const rootId = role === 'root' ? id : commentId(comment.reply_root_comment_id);
    const parentId = role === 'root' ? '' : commentId(comment.reply_comment_id);
    if (role === 'child' && rootId !== expectedRootId) {

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Read the surfaced __errorMessage/__errorCode in the message to identify the business error
  2. Compare the code against Zhihu API docs; add handling if it's a new known code
  3. Verify the request parameters (answer id, sort, order) are still valid
  4. Capture the full payload with -v and check for API schema changes

Example fix

// before
throw new CommandExecutionError(`... error payload: ${payload.__errorMessage || code}`);
// after
// at call site, branch on the code for better handling
catch (e) { if (e.message.includes('100001')) retryWithBackoff(); else throw e; }
Defensive patterns

Strategy: try-catch

Validate before calling

// validate parameters before request
if (!/^\d+$/.test(answerId)) throw new Error('invalid answer id');

Type guard

function isBusinessError(e){ return /error payload/i.test(String(e.message)); }

Try / catch

try { await fetchCommentPage(url); } catch (e) { const m = e.message.match(/error payload: (.+)$/); if (m) { log(`Zhihu business error: ${m[1]}`); /* map known codes to handling */ } throw e; }

Prevention

When it happens

Trigger: status < 400 but payload.__errorMessage or __errorCode set (and not 40362/40353/needLogin) — Zhihu returning 200 with a business-logic error body, or a payload whose shape regressed.

Common situations: Zhihu API returning {error: ...} bodies with 200; new error codes after API changes; comment feature disabled for the answer; malformed request producing an app-level error.

Related errors


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