{"record":{"id":"87d8c1dd6e499bd0","repo":"jackwener/OpenCLI","slug":"auth-required-87d8c1","errorCode":"AUTH_REQUIRED","errorMessage":"Yuanbao opened a login gate instead of returning a chat response.","messagePattern":"Yuanbao opened a login gate instead of returning a chat response\\.","errorType":"exception","errorClass":"AuthRequiredError","httpStatus":null,"severity":"error","filePath":"clis/yuanbao/ask.js","lineNumber":343,"sourceCode":"        const useThink = normalizeBooleanFlag(kwargs.think, false);\n        await ensureYuanbaoPage(page);\n        if (await hasLoginGate(page)) {\n            throw authRequired('Yuanbao opened a login gate before sending the prompt.');\n        }\n        await setYuanbaoInternetSearch(page, useSearch);\n        await setYuanbaoDeepThink(page, useThink);\n        const beforeAssistantMessages = await getYuanbaoAssistantMessages(page);\n        const beforeLines = await getYuanbaoTranscriptLines(page);\n        const sendResult = await sendYuanbaoMessage(page, prompt);\n        if (!sendResult?.ok) {\n            if (await hasLoginGate(page)) {\n                throw authRequired('Yuanbao opened a login gate instead of accepting the prompt.');\n            }\n            throw sendFailure(sendResult?.reason, sendResult?.detail);\n        }\n        const response = await waitForYuanbaoResponse(page, beforeAssistantMessages.length, beforeLines, prompt, timeout);\n        if (response === 'blocked') {\n            throw authRequired('Yuanbao opened a login gate instead of returning a chat response.');\n        }\n        if (!response) {\n            throw new TimeoutError('yuanbao ask', timeout, 'No Yuanbao response was observed before the timeout. Retry with --timeout, and verify the current browser session is still interactive.');\n        }\n        return [\n            { Role: 'User', Text: prompt },\n            { Role: 'Assistant', Text: response },\n        ];\n    },\n});\nexport const __test__ = {\n    collectYuanbaoTranscriptAdditions,\n    convertYuanbaoHtmlToMarkdown,\n    isOnYuanbao,\n    normalizeBooleanFlag,\n    pickLatestYuanbaoAssistantCandidate,\n    sanitizeYuanbaoResponseText,\n    updateStableState,","sourceCodeStart":325,"sourceCodeEnd":361,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/yuanbao/ask.js#L325-L361","documentation":"The prompt was accepted, but while waiting for the assistant response the CLI detected a login gate ('blocked' result from waitForYuanbaoResponse), meaning Yuanbao invalidated the session mid-conversation and threw AUTH_REQUIRED instead of timing out.","triggerScenarios":"waitForYuanbaoResponse returns 'blocked' because hasLoginGate became true between prompt submission and response arrival in the yuanbao ask flow.","commonSituations":"Session cookie expiring during a long wait; concurrent login elsewhere invalidating the session; Yuanbao injecting an auth wall for rate-limited or anonymous users mid-conversation.","solutions":["Log into Yuanbao in the automation browser and retry the ask command","Clear Yuanbao cookies and re-login to eliminate the stale session","Use an account with valid access to the agent and avoid concurrent logins from other devices","Reduce wait time/retry promptly after re-login so the session stays fresh"],"exampleFix":"// before: treating 'blocked' as a timeout\nconst response = await waitForYuanbaoResponse(...);\nif (!response) throw new TimeoutError(...);\n// after: handle blocked separately with re-auth\nif (response === 'blocked') { await yuanbaoLogin(); return yuanbaoAsk(prompt); }","handlingStrategy":"try-catch","validationCode":"await ensureYuanbaoPage(page);\nif (await hasLoginGate(page)) await yuanbaoLogin(page); // verify session before long waits","typeGuard":"function isAuthError(e) {\n  return e != null && (e.code === 'AUTH_REQUIRED' || /login gate/i.test(e?.message ?? ''));\n}","tryCatchPattern":"try {\n  return await yuanbaoAsk(page, prompt, { timeout });\n} catch (e) {\n  if (e.code === 'AUTH_REQUIRED') { await yuanbaoLogin(page); return yuanbaoAsk(page, prompt, { timeout }); }\n  if (e instanceof TimeoutError) { /* increase timeout or give up */ }\n  throw e;\n}","preventionTips":["Handle 'blocked' responses as auth, not timeout, in wrappers","Keep the session alive during long waits (heartbeat or shorter timeout + retry)","Avoid concurrent logins on the same account mid-conversation","Re-authenticate promptly after any AUTH_REQUIRED instead of retrying the same session"],"tags":["auth","browser-automation","yuanbao"],"backgroundTag":"login-gate-detected","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}