jackwener/OpenCLI · error · CommandExecutionError
${label}: ${String(payload.error)}
Error message
${label}: ${String(payload.error)} What it means
requireArrayEvaluateResult validates that an evaluate payload is an array. If instead it is an object with an `error` key, the library throws a CommandExecutionError prefixed with the extraction label and the raw error text. This surfaces in-page failures from shared weibo extraction helpers (called by data/rawData wrappers).
Source
Thrown at clis/weibo/utils.js:22
import { AuthRequiredError, CommandExecutionError } from '@jackwener/opencli/errors';
/**
* `page.evaluate` may return either the raw IIFE value or a
* `{ session, data }` envelope depending on the browser-bridge version.
* Adapter code that inspected the payload directly (e.g. `Array.isArray`,
* truthiness checks on uid strings) silently received the envelope wrapper
* instead of the inner value. This helper normalizes both shapes so callers
* can keep their existing checks unchanged.
*/
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;
}
/** Get the currently logged-in user's uid from Vue store or config API. */
export async function getSelfUid(page) {
const uid = unwrapEvaluateResult(await page.evaluate(`
(() => {
const app = document.querySelector('#app')?.__vue_app__;
const store = app?.config?.globalProperties?.$store;
const uid = store?.state?.config?.config?.uid;View on GitHub (pinned to 49907e53dc)
Solutions
- Read the `${label}: ...` prefix to identify which extractor failed and what the in-page error said.
- Re-authenticate the weibo.com session and retry.
- Retry after a delay if the error indicates rate limiting/anti-bot blocking.
- Update the CLI if Weibo changed its page structure.
Defensive patterns
Strategy: type-guard
Validate before calling
const payload = unwrapEvaluateResult(raw);
if (!Array.isArray(payload)) {
throw new Error(payload?.error ? `weibo: ${payload.error}` : 'weibo: non-array payload');
} Type guard
function isArrayPayload(p) {
return Array.isArray(p);
}
function payloadError(p) {
return p && typeof p === 'object' && !Array.isArray(p) && 'error' in p ? p.error : null;
} Try / catch
try {
const list = requireArrayEvaluateResult(raw, 'weibo search');
} catch (err) {
if (String(err.message).includes('malformed')) {
console.error('Extractor returned bad shape; check login/DOM');
} else throw err;
} Prevention
- Check the label prefix to identify the failing extractor
- Validate login state before running extraction
- Retry with backoff on suspected rate limiting
- Pin CLI versions and test after Weibo UI changes
When it happens
Trigger: Calling a weibo data/rawData command whose injected script returned {error: '...'} instead of an array; the label in the message identifies which extractor failed.
Common situations: Weibo rate-limiting or anti-bot interstitials cause the in-page script to report an error; login expired; the extractor's target element is missing after a Weibo UI update.
Related errors
- ${label} returned malformed extraction payload
- Chess.com API returned an unexpected payload shape for ${url
- ${label}
- Instagram profile returned malformed user payload for: ${use
- Unexpected SMZDM search extraction payload shape; expected a
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/b7e7fbe2cf07185b.
Report an issue: GitHub.