jackwener/OpenCLI · error · CommandExecutionError

${label}: ${String(payload.error)}

Error message

${label}: ${String(payload.error)}

What it means

requireArrayEvaluateResult validates that a page.evaluate extraction returned an array. If the injected script returned an object carrying an 'error' key (the in-page error envelope), the error string is rethrown as CommandExecutionError prefixed with the extraction label. Anything else non-array gets the generic malformed-payload message.

Source

Thrown at clis/chatgpt/utils.js:207

// `Array.isArray(payload)` directly on the envelope silently see "no data" —
// this matches the failure mode fixed for xiaohongshu/rednote (#1561) and
// weibo (#1568).
//
// `unwrapEvaluateResult` is a defensive ternary: it unwraps when the payload
// looks like an envelope, otherwise passes the value through unchanged so
// older bridge versions and primitive return values still work.
// ─────────────────────────────────────────────────────────────────────────────
export function unwrapEvaluateResult(payload) {
    if (payload && !Array.isArray(payload) && typeof payload === 'object' && 'session' in payload && 'data' in payload) {
        return payload.data;
    }
    return payload;
}

export function requireArrayEvaluateResult(payload, label) {
    if (!Array.isArray(payload)) {
        if (payload && typeof payload === 'object' && 'error' in payload) {
            throw new CommandExecutionError(`${label}: ${String(payload.error)}`);
        }
        throw new CommandExecutionError(`${label} returned malformed extraction payload`);
    }
    return payload;
}

export function requireObjectEvaluateResult(payload, label) {
    if (!payload || Array.isArray(payload) || typeof payload !== 'object') {
        throw new CommandExecutionError(`${label} returned malformed extraction payload`);
    }
    return payload;
}

export function requireBooleanEvaluateResult(payload, label) {
    if (typeof payload !== 'boolean') {
        throw new CommandExecutionError(`${label} returned malformed extraction payload`);
    }
    return payload;

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Read the ${label}: <error> text — it is the in-page script's own error message; fix the underlying condition (e.g. wait for the page to load)
  2. Retry the command after the page finishes rendering
  3. Verify you are on a chatgpt.com conversation/page the extractor supports
  4. Update the opencli package if ChatGPT's DOM changed (selector drift)

Example fix

// before
const items = await getChatGPTVisibleImageUrls(page); // throws 'image urls: selector not found'
// after
await page.waitForSelector('[data-testid="conversation"]', { timeout: 15000 });
const items = await getChatGPTVisibleImageUrls(page);
Defensive patterns

Strategy: try-catch

Type guard

function isArrayEvaluatePayload(p) { return Array.isArray(p); }

Try / catch

try { items = await getChatGPTVisibleImageUrls(page); } catch (e) { if (e instanceof CommandExecutionError) { console.error('extraction failed:', e.message); /* retry after wait */ } else throw e; }

Prevention

When it happens

Trigger: A chatgpt extraction script running in page.evaluate hits an in-page exception and returns {error: '...'}, or the page DOM changed so the script returns a non-array object/null.

Common situations: ChatGPT UI update renaming selectors, page not fully loaded so the target list is undefined, or being on a page where the extraction script bails with its own error envelope.

Related errors


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