jackwener/OpenCLI · error · CommandExecutionError
Weibo whoami returned no user id
Error message
Weibo whoami returned no user id
What it means
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.
Source
Thrown at clis/weibo/auth.js:54
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');
}
return verifyWeiboIdentity(page);
},
});
View on GitHub (pinned to 49907e53dc)
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
Example fix
null
Defensive patterns
Strategy: validation
Validate before calling
// ensure session cookies exist before calling whoami
const hasSession = await hasWeiboSessionCookie(page);
if (!hasSession) throw new Error('login required: SUB/SUBP cookies missing'); Type guard
function hasUserId(identity) {
return identity !== null && typeof identity === 'object' &&
typeof identity.user_id === 'string' && identity.user_id.length > 0;
} Try / catch
try {
identity = await verifyWeiboIdentity(page);
} catch (err) {
if (/returned no user id/.test(err.message)) {
// treat as expired session: trigger re-login flow
await runWeiboLogin(page);
identity = await verifyWeiboIdentity(page);
} else throw err;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Waiting for Weibo SUB / SUBP cookies
- Browser session required for weibo delete
- Not logged into Weibo. Please login at weibo.com in your Chr
- weibo.com
- 12306 tk auth cookie missing
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/cd150c86503ced08.
Report an issue: GitHub.