{"record":{"id":"178ab319b5a633f2","repo":"jackwener/OpenCLI","slug":"app-qianwen-com","errorCode":null,"errorMessage":"请在浏览器里用千问 APP 扫码登录 qianwen.com 后再重试。","messagePattern":"请在浏览器里用千问 APP 扫码登录 qianwen\\.com 后再重试。","errorType":"exception","errorClass":"AuthRequiredError","httpStatus":null,"severity":"error","filePath":"clis/qwen/ask.js","lineNumber":68,"sourceCode":"\n        await ensureOnQianwen(page);\n        await dismissLoginModal(page);\n\n        if (startFresh) {\n            await startNewChat(page);\n            await dismissLoginModal(page);\n        }\n\n        if (useThink) await setFeatureToggle(page, 'think', true);\n        if (useResearch) await setFeatureToggle(page, 'research', true);\n\n        // Anchor on the visible transcript BEFORE sending so waitForAnswer can\n        // bind the reply to the newly sent prompt instead of an older answer.\n        const baselineAnchor = await getBaselineChatAnchor(page);\n\n        const send = await sendMessage(page, prompt);\n        if (!send?.ok) {\n            if (await hasLoginGate(page)) throw authRequired();\n            throw new CommandExecutionError(send?.reason || 'Failed to send Qianwen prompt');\n        }\n\n        const result = await waitForAnswer(page, prompt, timeout, baselineAnchor);\n        if (result.status === 'auth_required') throw authRequired();\n        if (result.status === 'timeout') {\n            throw new TimeoutError('qianwen ask', timeout, 'No Qianwen reply observed before timeout. Retry with --timeout increased.');\n        }\n        const assistant = result.assistant;\n        if (!assistant) {\n            throw new CommandExecutionError('No assistant reply found in Qianwen chat.');\n        }\n        const answer = wantMarkdown && assistant.html\n            ? (bubbleHtmlToMarkdown(assistant.html) || assistant.text)\n            : assistant.text;\n        return [\n            { Role: 'User', Text: prompt },\n            { Role: 'Assistant', Text: answer },","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/qwen/ask.js#L50-L86","documentation":"This is the Qianwen CLI's AuthRequiredError (built by authRequired() in clis/qwen/utils.js:22). It is thrown when the automation cannot prove the browser session is logged into qianwen.com, because the entire qwen workflow (sending prompts, reading replies) depends on an authenticated session. The message instructs the user to scan a QR code with the Qianwen mobile app to log in before retrying.","triggerScenarios":"Running `qwen ask` when: (1) hasLoginGate(page) detects a login wall/modal after sendMessage fails to deliver the prompt, or (2) waitForAnswer reports result.status === 'auth_required' — i.e. the session was logged out or expired mid-conversation.","commonSituations":"The shared browser profile has no Qianwen login cookie or it expired; qianwen.com rotated its login wall so the session was invalidated; a fresh/incognito automation browser was used without prior manual login; a CAPTCHA or re-auth modal appeared mid-run.","solutions":["Open qianwen.com in the automation browser and log in by scanning the QR code with the Qianwen mobile app, then rerun the command","Persist the browser user-data/profile directory so the login cookie survives across runs","Re-check hasLoginGate detection: if you ARE logged in but still see this, the login-gate selector may have changed and needs updating","Rerun with a longer timeout in case the auth_required status came from a slow page load misdetected as a gate"],"exampleFix":"// before\nawait qwenAsk(prompt); // throws AuthRequiredError on expired session\n// after\ntry {\n  await qwenAsk(prompt);\n} catch (e) {\n  if (e.code === 'AUTH_REQUIRED') {\n    await loginQianwenViaQr(browser); // interactive QR login once, persisted profile\n    await qwenAsk(prompt);\n  }\n}","handlingStrategy":"try-catch","validationCode":"const url = await page.evaluate('window.location.href').catch(() => '');\nif (!url.includes('qianwen.com')) throw new Error('Not on qianwen.com — login first');","typeGuard":"function isAuthError(e) { return e && (e.code === 'AUTH_REQUIRED' || /扫码登录/.test(String(e.message))); }","tryCatchPattern":"try {\n  await qwenAsk(prompt);\n} catch (e) {\n  if (isAuthError(e)) {\n    await interactiveQianwenQrLogin();\n    return qwenAsk(prompt);\n  }\n  throw e;\n}","preventionTips":["Log into qianwen.com once via QR scan and persist the browser user-data directory between runs","Check login state (or call a cheap authenticated endpoint) before long commands","Avoid clearing cookies or rotating IPs/VPNs mid-session","Don't run concurrent sessions on the same Qianwen account that could invalidate each other"],"tags":["auth","login-required","browser-automation","qianwen"],"backgroundTag":"login-required","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}