{"record":{"id":"8fa363d59cc26efd","repo":"jackwener/OpenCLI","slug":"failed-to-send-qianwen-prompt","errorCode":null,"errorMessage":"Failed to send Qianwen prompt","messagePattern":"Failed to send Qianwen prompt","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/qwen/ask.js","lineNumber":69,"sourceCode":"        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 },\n        ];","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/qwen/ask.js#L51-L87","documentation":"CommandExecutionError thrown when sendMessage fails to submit the prompt to the Qianwen chat UI (send.ok falsy), carrying sendMessage's reason as the message. If a login gate is detected instead, an AuthRequiredError is thrown rather than this error.","triggerScenarios":"sendMessage returns {ok:false} because the composer/submit button could not be found or clicked, the textarea was not editable, or the page state was unexpected; reason string propagates into this error.","commonSituations":"Qianwen UI markup changed after a frontend deploy; page still loading when send was attempted; modal/overlay (login, rate-limit, maintenance banner) intercepting clicks; session logged out mid-flow.","solutions":["Read the send.reason embedded in the error to identify the exact DOM failure.","Re-login if a login gate appeared, then retry.","Retry after increasing pre-send wait times; refresh the page so the composer is fully hydrated.","Update the library if the Qianwen UI selectors changed (check for a newer version)."],"exampleFix":"// before\nconst out = await qwenAsk(page, { prompt: 'hi' });\n// after\ntry {\n  const out = await qwenAsk(page, { prompt: 'hi' });\n} catch (e) {\n  if (e instanceof CommandExecutionError) {\n    await page.reload();\n    await page.wait(5);\n    // retry once\n  } else throw e;\n}","handlingStrategy":"retry","validationCode":"// ensure page is settled before sending\nawait page.wait(3);\nif (await hasLoginGate(page)) { await qwenLogin(page); }","typeGuard":"function isSendFailure(e) {\n  return e instanceof CommandExecutionError && !/No assistant reply|timeout/i.test(e.message);\n}","tryCatchPattern":"try {\n  await qwenAsk(page, { prompt });\n} catch (e) {\n  if (e instanceof AuthRequiredError) { await qwenLogin(page); }\n  else if (isSendFailure(e)) {\n    await page.reload(); await page.wait(5);\n    await qwenAsk(page, { prompt }); // single retry\n  } else { throw e; }\n}","preventionTips":["Refresh/fully load the page before sending prompts","Detect login gates before automation runs","Keep the library current when the Qianwen UI changes","Log send.reason verbatim for diagnosis"],"tags":["browser-automation","dom","send-failed"],"backgroundTag":"page-interaction-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}