{"record":{"id":"cd150c86503ced08","repo":"jackwener/OpenCLI","slug":"weibo-whoami-returned-no-user-id","errorCode":null,"errorMessage":"Weibo whoami returned no user id","messagePattern":"Weibo whoami returned no user id","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/weibo/auth.js","lineNumber":54,"sourceCode":"  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');\n    }\n    return verifyWeiboIdentity(page);\n  },\n});\n","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/weibo/auth.js#L36-L72","documentation":"The probe succeeded (ok:true) but the authenticated user's id (user_id from the /ajax/profile/info response) is missing or empty. The library requires user_id as the primary identity field for the whoami result, so it refuses to return a partial identity.","triggerScenarios":"Weibo returns ok:true but omits user_id — typically when the SUB/SUBP session cookies are present but invalid/expired server-side, or the profile info response is for a logged-out/limited view.","commonSituations":"Half-expired sessions where cookies exist but the server no longer recognizes them, freshly logged-in accounts pending full session activation, or accounts restricted by Weibo (unverified/limited) that don't expose user_id via this endpoint.","solutions":["Log out and log back in to weibo.com to obtain fresh SUB/SUBP cookies, then retry whoami","Verify the session manually in a browser — if weibo.com shows you logged out, the cookies are stale","Wait and retry if the account was just created/restricted; user_id may be temporarily withheld","Update the library if Weibo changed the field name in the profile info response"],"exampleFix":"null","handlingStrategy":"validation","validationCode":"// ensure session cookies exist before calling whoami\nconst hasSession = await hasWeiboSessionCookie(page);\nif (!hasSession) throw new Error('login required: SUB/SUBP cookies missing');","typeGuard":"function hasUserId(identity) {\n  return identity !== null && typeof identity === 'object' &&\n    typeof identity.user_id === 'string' && identity.user_id.length > 0;\n}","tryCatchPattern":"try {\n  identity = await verifyWeiboIdentity(page);\n} catch (err) {\n  if (/returned no user id/.test(err.message)) {\n    // treat as expired session: trigger re-login flow\n    await runWeiboLogin(page);\n    identity = await verifyWeiboIdentity(page);\n  } else throw err;\n}","preventionTips":["Refresh the weibo.com login periodically; SUB/SUBP cookies expire server-side","Verify whoami right after login to confirm the session is fully active","Check account status in a normal browser if user_id is consistently missing","Don't rely on cookie presence alone — always run identity verification"],"tags":["weibo","authentication","session-validation"],"backgroundTag":"session-cookie-invalid","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}