{"record":{"id":"2e8564bbd8384100","repo":"jackwener/OpenCLI","slug":"yuanbao-opened-a-login-gate-before-sending-the-pro","errorCode":null,"errorMessage":"Yuanbao opened a login gate before sending the prompt. ${SESSION_HINT}","messagePattern":"Yuanbao opened a login gate before sending the prompt\\. (.+?)","errorType":"exception","errorClass":"AuthRequiredError","httpStatus":null,"severity":"error","filePath":"clis/yuanbao/ask.js","lineNumber":328,"sourceCode":"    defaultFormat: 'plain',\n    args: [\n        { name: 'prompt', required: true, positional: true, help: 'Prompt to send' },\n        { name: 'timeout', type: 'int', required: false, help: 'Max seconds to wait (default: 60)', default: 60 },\n        { name: 'search', type: 'boolean', required: false, help: 'Enable Yuanbao internet search (default: true)', default: true },\n        { name: 'think', type: 'boolean', required: false, help: 'Enable Yuanbao deep thinking (default: false)', default: false },\n    ],\n    columns: ['Role', 'Text'],\n    func: async (page, kwargs) => {\n        const prompt = kwargs.prompt;\n        const timeout = kwargs.timeout;\n        if (!Number.isInteger(timeout) || timeout < 1) {\n            throw new ArgumentError('--timeout must be a positive integer (seconds)');\n        }\n        const useSearch = normalizeBooleanFlag(kwargs.search, true);\n        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.');","sourceCodeStart":310,"sourceCodeEnd":346,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/yuanbao/ask.js#L310-L346","documentation":"Before sending the prompt, the Yuanbao web page already shows a login gate (auth wall), so the CLI aborts with an AUTH_REQUIRED error rather than submitting a message that would fail. SESSION_HINT is appended to guide the user to fix their browser session.","triggerScenarios":"Calling the yuanbao ask command when ensureYuanbaoPage leaves the page in a logged-out state and hasLoginGate(page) returns true prior to sendYuanbaoMessage.","commonSituations":"Expired Yuanbao/tencent browser cookies; headless browser profile never logged in; Yuanbao forced re-login after policy change or long inactivity; incognito profile without persisted session.","solutions":["Open the browser profile used by the CLI and log into Yuanbao manually to refresh the session","Clear Yuanbao cookies and re-login so no stale gate-triggering cookies remain","Verify YUANBAO_URL points to the correct, non-login-redirecting host","Re-run the command immediately after login while the session cookie is fresh"],"exampleFix":"// before: assuming a session exists\nawait ensureYuanbaoPage(page);\nawait sendYuanbaoMessage(page, prompt);\n// after: caller checks and re-authenticates on AUTH_REQUIRED\ntry {\n  await yuanbaoAsk(prompt);\n} catch (e) {\n  if (e.code === 'AUTH_REQUIRED') { await yuanbaoLogin(); return yuanbaoAsk(prompt); }\n  throw e;\n}","handlingStrategy":"validation","validationCode":"import { hasLoginGate } from './yuanbao/page.js';\nawait ensureYuanbaoPage(page);\nif (await hasLoginGate(page)) {\n  await yuanbaoLogin(page); // re-auth before calling ask\n}","typeGuard":"async function isYuanbaoSessionValid(page) {\n  return !(await hasLoginGate(page));\n}","tryCatchPattern":"try {\n  return await yuanbaoAsk(page, prompt);\n} catch (e) {\n  if (e.code === 'AUTH_REQUIRED') {\n    await yuanbaoLogin(page);\n    return yuanbaoAsk(page, prompt);\n  }\n  throw e;\n}","preventionTips":["Log into Yuanbao in the persistent browser profile before running commands","Schedule periodic session refresh so cookies don't expire between runs","Check hasLoginGate right after page load in your own wrapper","Avoid concurrent logins that invalidate the automation session"],"tags":["auth","browser-automation","yuanbao"],"backgroundTag":"login-gate-detected","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}