{"record":{"id":"b953d6d4fdcb965f","repo":"jackwener/OpenCLI","slug":"prompt-is-required-b953d6","errorCode":null,"errorMessage":"prompt is required","messagePattern":"prompt is required","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/qwen/ask.js","lineNumber":41,"sourceCode":"    description: 'Send a prompt to Qianwen and return the assistant reply',\n    domain: QIANWEN_DOMAIN,\n    strategy: Strategy.COOKIE,\n    browser: true,\n    siteSession: 'persistent',\n    navigateBefore: false,\n    defaultFormat: 'plain',\n    args: [\n        { name: 'prompt', required: true, positional: true, help: 'Prompt to send to Qianwen' },\n        { name: 'timeout', type: 'int', default: 120, help: 'Max seconds to wait for the response' },\n        { name: 'new', type: 'boolean', default: false, help: 'Start a new chat before sending' },\n        { name: 'think', type: 'boolean', default: false, help: 'Enable 深度思考 (DeepThink)' },\n        { name: 'research', type: 'boolean', default: false, help: 'Enable 深度研究 (DeepResearch)' },\n        { name: 'markdown', type: 'boolean', default: false, help: 'Emit assistant reply as markdown' },\n    ],\n    columns: ['Role', 'Text'],\n    func: async (page, kwargs) => {\n        const prompt = String(kwargs.prompt || '').trim();\n        if (!prompt) throw new ArgumentError('prompt is required');\n        const timeout = Number(kwargs.timeout ?? 120);\n        if (!Number.isInteger(timeout) || timeout <= 0) {\n            throw new ArgumentError('timeout must be a positive integer');\n        }\n        const startFresh = normalizeBooleanFlag(kwargs.new, false);\n        const useThink = normalizeBooleanFlag(kwargs.think, false);\n        const useResearch = normalizeBooleanFlag(kwargs.research, false);\n        const wantMarkdown = normalizeBooleanFlag(kwargs.markdown, false);\n\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);","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/qwen/ask.js#L23-L59","documentation":"ArgumentError thrown by the qwen ask command's func when the --prompt keyword is missing or trims to an empty string. It is upfront input validation before any browser automation runs.","triggerScenarios":"Running `qwen ask` without --prompt, with --prompt \"\" or only whitespace; programmatic invocation passing kwargs without a prompt key.","commonSituations":"Shell quoting issues losing the argument; a script building the command with an empty variable; copy-pasting a command without the prompt value.","solutions":["Pass a non-empty --prompt value.","In scripts, default or assert the prompt variable before invoking: [ -n \"$PROMPT\" ] || exit 1.","Quote the prompt to survive spaces in the shell."],"exampleFix":"// before\nqwen ask --prompt \"\" --timeout 120\n// after\nqwen ask --prompt \"Summarize this repo\" --timeout 120","handlingStrategy":"validation","validationCode":"const prompt = String(process.argv.prompt || '').trim();\nif (!prompt) { console.error('usage: qwen ask --prompt \"...\"'); process.exit(2); }","typeGuard":"function hasPrompt(kwargs) {\n  return typeof kwargs.prompt === 'string' && kwargs.prompt.trim().length > 0;\n}","tryCatchPattern":"try {\n  await qwenAsk(page, { prompt });\n} catch (e) {\n  if (e instanceof ArgumentError && /prompt/.test(e.message)) {\n    console.error('A non-empty --prompt is required');\n  } else { throw e; }\n}","preventionTips":["Always quote --prompt values in shell scripts","Assert prompt variables are non-empty before invoking","Fail fast in wrappers with a usage message"],"tags":["validation","arguments","cli"],"backgroundTag":"missing-required-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}