jackwener/OpenCLI · error · AuthRequiredError
Yuanbao hy_user cookie missing — anonymous session
Error message
Yuanbao hy_user cookie missing — anonymous session
What it means
An AuthRequiredError thrown by verifyYuanbaoIdentity when no login gate is visible but the session's cookies for yuanbao.tencent.com contain no non-empty `hy_user` cookie — Yuanbao's user-identity cookie. The page may look logged out or half-authenticated, so the verifier treats the session as anonymous and refuses to proceed.
Source
Thrown at clis/yuanbao/auth.js:18
import { AuthRequiredError, CommandExecutionError } from '@jackwener/opencli/errors';
import { registerSiteAuthCommands } from '../_shared/site-auth.js';
import { hasLoginGate, ensureYuanbaoPage, YUANBAO_DOMAIN, YUANBAO_URL } from './shared.js';
async function hasYuanbaoUserCookie(page) {
const cookies = await page.getCookies({ url: 'https://yuanbao.tencent.com' });
return cookies.some(c => c.name === 'hy_user' && c.value);
}
async function verifyYuanbaoIdentity(page) {
await ensureYuanbaoPage(page);
if (await hasLoginGate(page)) {
throw new AuthRequiredError(YUANBAO_DOMAIN, 'Yuanbao showed wx login gate — anonymous session');
}
const cookies = await page.getCookies({ url: 'https://yuanbao.tencent.com' });
const hyUser = cookies.find(c => c.name === 'hy_user')?.value || '';
if (!hyUser) {
throw new AuthRequiredError(YUANBAO_DOMAIN, 'Yuanbao hy_user cookie missing — anonymous session');
}
const probe = await page.evaluate(`
(() => {
const bodyText = document.body?.innerText || '';
const nickMatch = bodyText.match(/用户[a-z0-9]{4,}/i);
const state = window.__INITIAL_STATE__ || {};
const seen = new Set();
const stack = [state];
let stateNick = '';
while (stack.length) {
const node = stack.pop();
if (!node || typeof node !== 'object' || seen.has(node)) continue;
seen.add(node);
if (Array.isArray(node)) { stack.push(...node); continue; }
const u = node.userInfo || node.user;
if (u && typeof u === 'object' && (u.nickname || u.nick)) {
stateNick = String(u.nickname || u.nick);
break;View on GitHub (pinned to 49907e53dc)
Solutions
- Re-run the yuanbao login flow to obtain a fresh complete cookie set.
- Check that imported cookies include a non-empty hy_user for yuanbao.tencent.com.
- Clear the session and log in again — half-valid cookies cause this state.
Defensive patterns
Strategy: validation
Validate before calling
const cookies = await page.getCookies({ url: 'https://yuanbao.tencent.com' });
const hyUser = cookies.find(c => c.name === 'hy_user')?.value || '';
if (!hyUser) throw new Error('Session lacks hy_user cookie — run yuanbao login first'); Type guard
const hasHyUser = (cookies) => Array.isArray(cookies) && typeof cookies.find(c => c.name === 'hy_user')?.value === 'string' && cookies.find(c => c.name === 'hy_user').value.length > 0;
Try / catch
try {
await run(['yuanbao', 'whoami']);
} catch (e) {
if (/hy_user cookie missing/.test(e.message)) {
await run(['yuanbao', 'login']);
} else throw e;
} Prevention
- When importing cookies manually, ensure hy_user is present and non-empty
- Re-login when cookies are half-expired (gate not shown but session invalid)
- Check cookie domain/scope matches yuanbao.tencent.com
- Disable extensions/profiles that strip cookies during automation
When it happens
Trigger: Running a yuanbao command whose verify step checks cookies when the hy_user cookie is missing, empty, expired server-side, or scoped to a different URL so page.getCookies({ url: 'https://yuanbao.tencent.com' }) doesn't return it.
Common situations: Cookie partially expired (gate not shown yet but session invalidated); manually imported cookie set missing hy_user; cookie domain mismatch after a site domain change; privacy extensions stripping cookies.
Related errors
- Boss wt2 / t cookies missing
- Instagram story publish could not derive current user id fro
- Not logged into x.com (no ct0 cookie)
- 12306 tk auth cookie missing
- amazon.com
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/4bee82a75fce8cc0.
Report an issue: GitHub.