jackwener/OpenCLI · error · AuthRequiredError
Xianyu chat requires a logged-in browser session
Error message
Xianyu chat requires a logged-in browser session
What it means
The chat page extract returned state.requiresAuth=true, meaning goofish.com served the chat without a logged-in session, so messages cannot be read or sent. The library throws AuthRequiredError to abort the chat command until the user logs in.
Source
Thrown at clis/xianyu/chat.js:30
strategy: Strategy.COOKIE,
navigateBefore: false,
browser: true,
args: [
{ name: 'item_id', required: true, positional: true, help: '闲鱼商品 item_id' },
{ name: 'user_id', required: true, positional: true, help: '聊一聊对方的 user_id / peerUserId' },
{ name: 'text', help: 'Message to send after opening the chat' },
],
columns: ['status', 'peer_name', 'item_title', 'price', 'location', 'message'],
func: async (page, kwargs) => {
const itemId = normalizeNumericId(kwargs.item_id, 'item_id', '1038951278192');
const userId = normalizeNumericId(kwargs.user_id, 'user_id', '3650092411');
const url = buildChatUrl(itemId, userId);
const text = String(kwargs.text || '').trim();
await page.goto(url);
await page.wait(2);
const state = requireEvaluateObject(await page.evaluate(buildExtractChatStateEvaluate()), 'chat');
if (state?.requiresAuth) {
throw new AuthRequiredError('www.goofish.com', 'Xianyu chat requires a logged-in browser session');
}
if (!state?.can_input) {
throw selectorError('闲鱼聊天输入框', '未找到可用的聊天输入框,请确认该会话页已正确加载');
}
if (!text) {
return [{
status: 'ready',
peer_name: state.peer_name || '',
item_title: state.item_title || '',
price: state.price || '',
location: state.location || '',
message: (state.visible_messages || []).slice(-1)[0] || '',
peer_user_id: userId,
item_id: itemId,
url,
item_url: state.item_url || '',
}];
}View on GitHub (pinned to 49907e53dc)
Solutions
- Log in to www.goofish.com in the same browser session, then retry the chat command
- Restore a valid cookie/user-data-dir profile before running chat commands
- Add a quick auth check (e.g. hasXianyuIdentityCookie) before invoking chat
- Catch AuthRequiredError and route the user to the login flow
Example fix
// before
await sendXianyuChat({ itemId, userId, text });
// after
if (!(await hasXianyuIdentityCookie(page))) {
await loginXianyu(page);
}
await sendXianyuChat({ itemId, userId, text }); Defensive patterns
Strategy: try-catch
Validate before calling
if (!(await hasXianyuIdentityCookie(page))) {
await loginXianyu(page);
} Type guard
function isAuthRequiredError(e) {
return e instanceof AuthRequiredError || e?.name === 'AuthRequiredError';
} Try / catch
try {
await sendXianyuChat(kwargs);
} catch (e) {
if (isAuthRequiredError(e)) {
await loginXianyu(page);
return sendXianyuChat(kwargs);
}
throw e;
} Prevention
- Run a quick auth check before chat operations
- Keep the session alive with periodic /personal probes
- Use one shared browser profile for login and chat commands
When it happens
Trigger: Calling the xianyu chat send command when the browser session is anonymous; buildExtractChatStateEvaluate detects a login wall on the chat URL.
Common situations: Session cookies expired between login and chat use; fresh browser profile never logged in; goofish logged the session out due to risk control.
Related errors
- Xianyu /personal shows login prompt — anonymous
- Waiting for Xianyu unb/tracknick cookie
- Xianyu chat did not observe the sent message: ${sent?.reason
- Xianyu item detail requires a logged-in browser session
- 请先在共享 Chrome 完成 1688 登录/验证,再重试(${action})
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/1bebed5079e7ed04.
Report an issue: GitHub.