{"record":{"id":"46c127797460e70c","repo":"jackwener/OpenCLI","slug":"prompt-is-required-46c127","errorCode":null,"errorMessage":"prompt is required","messagePattern":"prompt is required","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/qwen/image.js","lineNumber":115,"sourceCode":"    access: 'write',\n    description: 'Generate images with Qianwen (AI生图) and save them locally',\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: 'Image prompt to send' },\n        { name: 'op', default: '~/Pictures/qianwen', help: 'Output directory' },\n        { name: 'new', type: 'boolean', default: true, help: 'Start a new chat before generating (default: true)' },\n        { name: 'sd', type: 'boolean', default: false, help: 'Skip download; only show the Qianwen link' },\n        { name: 'timeout', type: 'int', default: 180, help: 'Max seconds to wait for the image response' },\n    ],\n    columns: ['Status', 'File', 'Link'],\n    func: async (page, kwargs) => {\n        const prompt = String(kwargs.prompt || '').trim();\n        if (!prompt) throw new ArgumentError('prompt is required');\n        const outputDir = String(kwargs.op || '~/Pictures/qianwen').replace(/^~\\//, `${os.homedir()}/`);\n        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);","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/qwen/image.js#L97-L133","documentation":"The `qwen image` command requires a prompt: it trims String(kwargs.prompt || '') and, if empty, throws ArgumentError('prompt is required') at clis/qwen/image.js:115 before touching the browser. No image generation request is made without prompt text.","triggerScenarios":"Calling the image command's func with kwargs.prompt missing, empty string, whitespace-only, or null/undefined — e.g. `qwen image` with no --prompt argument, or a script passing an unset variable.","commonSituations":"Forgetting the positional/flag prompt in a shell alias; automation passing an empty prompt after stripping invalid characters; kwargs key mismatch (passing 'text' or 'query' instead of 'prompt').","solutions":["Provide the prompt: qwen image --prompt \"a red fox in snow\".","Check you're using the correct kwarg name ('prompt', not 'text'/'query').","In scripts, guard before calling: const p = String(kwargs.prompt||'').trim(); if (!p) fail early with a clear message.","Quote the prompt in the shell so multi-word text isn't split/dropped."],"exampleFix":"// before\nqwen image --text \"a cat\"   # wrong kwarg -> prompt missing\n// after\nqwen image --prompt \"a cat\"","handlingStrategy":"validation","validationCode":"const prompt = String(kwargs.prompt || '').trim();\nif (!prompt) throw new Error('prompt is required: pass --prompt \"<text>\"');","typeGuard":"function hasPrompt(kwargs) {\n  return typeof kwargs.prompt === 'string' && kwargs.prompt.trim().length > 0;\n}","tryCatchPattern":"try {\n  await qwenImage({ prompt });\n} catch (e) {\n  if (e instanceof ArgumentError && /prompt is required/.test(e.message)) {\n    throw new UsageError('Usage: qwen image --prompt \"<description>\" [--op dir] [--timeout 180]');\n  } else throw e;\n}","preventionTips":["Always pass --prompt and quote multi-word text in the shell.","Use the exact kwarg name 'prompt' when calling the func programmatically.","Trim and check prompt non-empty at the boundary of your wrapper scripts.","Print usage on empty prompt instead of forwarding empty strings."],"tags":["validation","argument-error","cli","qwen"],"backgroundTag":"missing-required-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}