{"record":{"id":"c9aeb00117b02968","repo":"jackwener/OpenCLI","slug":"app-qianwen-com-c9aeb0","errorCode":null,"errorMessage":"请在浏览器里用千问 APP 扫码登录 qianwen.com 后再重试。","messagePattern":"请在浏览器里用千问 APP 扫码登录 qianwen\\.com 后再重试。","errorType":"exception","errorClass":"AuthRequiredError","httpStatus":null,"severity":"error","filePath":"clis/qwen/image.js","lineNumber":135,"sourceCode":"        const startFresh = normalizeBooleanFlag(kwargs.new, true);\n        const skipDownload = normalizeBooleanFlag(kwargs.sd, false);\n        const timeout = Number(kwargs.timeout ?? 180);\n        if (!Number.isInteger(timeout) || timeout <= 0) {\n            throw new ArgumentError('timeout must be a positive integer');\n        }\n\n        await ensureOnQianwen(page);\n        await dismissLoginModal(page);\n        if (startFresh) {\n            await startNewChat(page);\n            await dismissLoginModal(page);\n        }\n        await setFeatureToggle(page, 'image', true);\n        await page.wait(0.5);\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 image prompt');\n        }\n\n        // Grab the newest assistant bubble id after send by polling briefly\n        let targetId = '';\n        for (let i = 0; i < 5; i += 1) {\n            await page.wait(1);\n            const bubbles = await getMessageBubbles(page);\n            const lastAnswer = [...bubbles].reverse().find((b) => b.role === 'Assistant');\n            if (lastAnswer) { targetId = lastAnswer.id; break; }\n        }\n\n        const waitResult = await waitForImageUrls(page, targetId, timeout);\n        const link = await page.evaluate('window.location.href').catch(() => 'https://www.qianwen.com/');\n        if (waitResult.status === 'auth_required') throw authRequired();\n        if (waitResult.status === 'timeout') {\n            throw new TimeoutError('qianwen image', timeout, 'No generated images observed before timeout.');\n        }","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/qwen/image.js#L117-L153","documentation":"AuthRequiredError raised by `qwen image` when the image-generation prompt cannot be sent because a login gate is detected on the page. Image generation typically requires a stricter/longer-lived session than chat, so an unauthenticated or recently expired session fails at the sendMessage step via hasLoginGate() -> authRequired().","triggerScenarios":"`qwen image` toggles the image feature, calls sendMessage(page, prompt), the send fails (send.ok is falsy), and hasLoginGate(page) then finds a login wall/modal on qianwen.com.","commonSituations":"Generating images without ever logging in in that browser profile; session expired between runs (image runs are long, cookies may lapse); qianwen.com demanding re-login before allowing image features.","solutions":["Scan the QR code with the Qianwen APP to log in at qianwen.com in the automation browser, then rerun `qwen image`","Log in once interactively and persist the profile directory so subsequent image runs reuse the session","If the send failure is not actually a login gate, check hasLoginGate's selectors against the current qianwen.com UI (false positives surface as this error)","Retry shortly after logging in — new sessions sometimes need one page reload before the composer accepts input"],"exampleFix":"// before\nconst send = await sendMessage(page, prompt);\nif (!send?.ok) {\n  if (await hasLoginGate(page)) throw authRequired();\n// after (caller pre-check)\nif (!(await isQianwenLoggedIn(page))) {\n  await promptQrLogin(); // avoid failing mid-image-run\n}\nconst send = await sendMessage(page, prompt);","handlingStrategy":"validation","validationCode":"async function assertQianwenLoggedIn(page) {\n  const gate = await page.evaluate(() => !!document.querySelector('[class*=login-wall], [class*=login-modal]'));\n  if (gate) throw new Error('Login required before image generation — scan QR with Qianwen APP');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await qwenImage(prompt);\n} catch (e) {\n  if (isAuthError(e)) { await ensureQianwenLogin(); return qwenImage(prompt); }\n  throw e;\n}","preventionTips":["Verify login before starting image runs — they are long and costly to restart","Persist cookies in the automation profile","Reload qianwen.com after login so the composer/toggles initialize for the new session","Watch for UI changes to login-gate markers that could cause false auth detection"],"tags":["auth","login-required","image-generation","qianwen"],"backgroundTag":"login-required","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}