jackwener/OpenCLI · error · CommandExecutionError
Weibo whoami failed: ${result.detail}
Error message
Weibo whoami failed: ${result.detail} What it means
verifyWeiboIdentity runs an in-page probe of the weibo.com whoami/profile endpoint. The probe script wraps its execution in a try/catch and returns {kind:'exception', detail} when something throws inside the browser context; the Node side converts that into a CommandExecutionError. This means the page itself threw while executing the probe, not that auth or HTTP status failed.
Source
Thrown at clis/weibo/auth.js:49
}
})()`;
}
async function verifyWeiboIdentity(page) {
if (!await hasWeiboSessionCookie(page)) {
throw new AuthRequiredError('weibo.com', 'Weibo SUB / SUBP cookies missing');
}
await page.goto('https://weibo.com/');
await page.wait(3);
// getSelfUid throws AuthRequiredError when no logged-in uid can be resolved.
const uid = await getSelfUid(page);
if (typeof uid !== 'string' || !uid.trim()) {
throw new CommandExecutionError('Weibo uid resolver returned a malformed uid');
}
const result = unwrapEvaluateResult(await page.evaluate(buildWeiboIdentityProbe(uid)));
if (result?.kind === 'auth') throw new AuthRequiredError('weibo.com', result.detail);
if (result?.kind === 'http') throw new CommandExecutionError(`HTTP ${result.httpStatus} from /ajax/profile/info`);
if (result?.kind === 'exception') throw new CommandExecutionError(`Weibo whoami failed: ${result.detail}`);
if (!result || Array.isArray(result) || typeof result !== 'object') {
throw new CommandExecutionError('Weibo whoami returned malformed probe payload');
}
if (!result?.ok) throw new CommandExecutionError(`Unexpected Weibo probe: ${JSON.stringify(result)}`);
if (!result.user_id) throw new CommandExecutionError('Weibo whoami returned no user id');
return { user_id: result.user_id, screen_name: result.screen_name, profile_url: result.profile_url };
}
registerSiteAuthCommands({
site: 'weibo',
domain: 'weibo.com',
loginUrl: 'https://weibo.com/login',
columns: ['user_id', 'screen_name', 'profile_url'],
quickCheck: hasWeiboSessionCookie,
verify: verifyWeiboIdentity,
poll: async (page) => {
if (!await hasWeiboSessionCookie(page)) {
throw new AuthRequiredError('weibo.com', 'Waiting for Weibo SUB / SUBP cookies');View on GitHub (pinned to 49907e53dc)
Solutions
- Retry after a longer settle delay — the page may still be initializing; add page.wait before the probe
- Check the result.detail string in the message to identify the in-page exception and address it (e.g. blocked fetch)
- Re-login to get a clean session; anti-bot or broken cookies can make Weibo scripts throw
- Update the library — a Weibo frontend change may require a probe fix
Example fix
// before const result = unwrapEvaluateResult(await page.evaluate(buildWeiboIdentityProbe(uid))); // after await page.wait(3); // let the page settle before probing const result = unwrapEvaluateResult(await page.evaluate(buildWeiboIdentityProbe(uid)));
Defensive patterns
Strategy: try-catch
Validate before calling
// retry once with a settle delay if the probe throws
if (/Weibo whoami failed/.test(err.message)) {
await page.wait(3);
return verifyWeiboIdentity(page);
} Type guard
function isProbeException(r) {
return r !== null && typeof r === 'object' && !Array.isArray(r) && r.kind === 'exception';
} Try / catch
try {
identity = await verifyWeiboIdentity(page);
} catch (err) {
if (err instanceof CommandExecutionError && /whoami failed/.test(err.message)) {
await page.wait(3);
identity = await verifyWeiboIdentity(page); // single retry
} else throw err;
} Prevention
- Let the page fully settle (wait a few seconds after navigation) before probing
- Avoid running with extensions or anti-bot tooling that patches fetch/XHR on weibo.com
- Keep the library updated against Weibo frontend changes
- Retry once before surfacing the error; in-page exceptions are often transient
When it happens
Trigger: The page.evaluate(buildWeiboIdentityProbe(uid)) callback throws in the browser: undefined browser APIs (e.g. fetch or XMLHttpRequest monkey-patched/blocked by page scripts or extensions), a Content Security Policy violation blocking the probe's fetch to /ajax/profile/info, or an unexpected DOM/JSON shape that the probe dereferences.
Common situations: Running the CLI against a heavily customized weibo.com page, anti-bot scripts interfering with the injected probe, page still mid-load with scripts overriding fetch, or a Weibo frontend redesign changing response parsing in the probe.
Related errors
- Weibo whoami returned malformed probe payload
- Unexpected Weibo probe: ${JSON.stringify(result)}
- Cookie 已过期!请在当前 Chrome 浏览器中重新登录 Weibo。
- String(data.error)
- Browser session required for weibo publish
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/44e707e656b346de.
Report an issue: GitHub.