{"record":{"id":"44e707e656b346de","repo":"jackwener/OpenCLI","slug":"weibo-whoami-failed-result-detail","errorCode":null,"errorMessage":"Weibo whoami failed: ${result.detail}","messagePattern":"Weibo whoami failed: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/weibo/auth.js","lineNumber":49,"sourceCode":"    }\n  })()`;\n}\n\nasync function verifyWeiboIdentity(page) {\n  if (!await hasWeiboSessionCookie(page)) {\n    throw new AuthRequiredError('weibo.com', 'Weibo SUB / SUBP cookies missing');\n  }\n  await page.goto('https://weibo.com/');\n  await page.wait(3);\n  // getSelfUid throws AuthRequiredError when no logged-in uid can be resolved.\n  const uid = await getSelfUid(page);\n  if (typeof uid !== 'string' || !uid.trim()) {\n    throw new CommandExecutionError('Weibo uid resolver returned a malformed uid');\n  }\n  const result = unwrapEvaluateResult(await page.evaluate(buildWeiboIdentityProbe(uid)));\n  if (result?.kind === 'auth') throw new AuthRequiredError('weibo.com', result.detail);\n  if (result?.kind === 'http') throw new CommandExecutionError(`HTTP ${result.httpStatus} from /ajax/profile/info`);\n  if (result?.kind === 'exception') throw new CommandExecutionError(`Weibo whoami failed: ${result.detail}`);\n  if (!result || Array.isArray(result) || typeof result !== 'object') {\n    throw new CommandExecutionError('Weibo whoami returned malformed probe payload');\n  }\n  if (!result?.ok) throw new CommandExecutionError(`Unexpected Weibo probe: ${JSON.stringify(result)}`);\n  if (!result.user_id) throw new CommandExecutionError('Weibo whoami returned no user id');\n  return { user_id: result.user_id, screen_name: result.screen_name, profile_url: result.profile_url };\n}\n\nregisterSiteAuthCommands({\n  site: 'weibo',\n  domain: 'weibo.com',\n  loginUrl: 'https://weibo.com/login',\n  columns: ['user_id', 'screen_name', 'profile_url'],\n  quickCheck: hasWeiboSessionCookie,\n  verify: verifyWeiboIdentity,\n  poll: async (page) => {\n    if (!await hasWeiboSessionCookie(page)) {\n      throw new AuthRequiredError('weibo.com', 'Waiting for Weibo SUB / SUBP cookies');","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/weibo/auth.js#L31-L67","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nconst result = unwrapEvaluateResult(await page.evaluate(buildWeiboIdentityProbe(uid)));\n// after\nawait page.wait(3); // let the page settle before probing\nconst result = unwrapEvaluateResult(await page.evaluate(buildWeiboIdentityProbe(uid)));","handlingStrategy":"try-catch","validationCode":"// retry once with a settle delay if the probe throws\nif (/Weibo whoami failed/.test(err.message)) {\n  await page.wait(3);\n  return verifyWeiboIdentity(page);\n}","typeGuard":"function isProbeException(r) {\n  return r !== null && typeof r === 'object' && !Array.isArray(r) && r.kind === 'exception';\n}","tryCatchPattern":"try {\n  identity = await verifyWeiboIdentity(page);\n} catch (err) {\n  if (err instanceof CommandExecutionError && /whoami failed/.test(err.message)) {\n    await page.wait(3);\n    identity = await verifyWeiboIdentity(page); // single retry\n  } else throw err;\n}","preventionTips":["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"],"tags":["weibo","browser-automation","page-evaluation"],"backgroundTag":"in-page-probe-exception","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}