jackwener/OpenCLI · error · ArgumentError

prompt is required

Error message

prompt is required

What it means

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.

Source

Thrown at clis/qwen/image.js:115

    access: 'write',
    description: 'Generate images with Qianwen (AI生图) and save them locally',
    domain: QIANWEN_DOMAIN,
    strategy: Strategy.COOKIE,
    browser: true,
    siteSession: 'persistent',
    navigateBefore: false,
    defaultFormat: 'plain',
    args: [
        { name: 'prompt', required: true, positional: true, help: 'Image prompt to send' },
        { name: 'op', default: '~/Pictures/qianwen', help: 'Output directory' },
        { name: 'new', type: 'boolean', default: true, help: 'Start a new chat before generating (default: true)' },
        { name: 'sd', type: 'boolean', default: false, help: 'Skip download; only show the Qianwen link' },
        { name: 'timeout', type: 'int', default: 180, help: 'Max seconds to wait for the image response' },
    ],
    columns: ['Status', 'File', 'Link'],
    func: async (page, kwargs) => {
        const prompt = String(kwargs.prompt || '').trim();
        if (!prompt) throw new ArgumentError('prompt is required');
        const outputDir = String(kwargs.op || '~/Pictures/qianwen').replace(/^~\//, `${os.homedir()}/`);
        const startFresh = normalizeBooleanFlag(kwargs.new, true);
        const skipDownload = normalizeBooleanFlag(kwargs.sd, false);
        const timeout = Number(kwargs.timeout ?? 180);
        if (!Number.isInteger(timeout) || timeout <= 0) {
            throw new ArgumentError('timeout must be a positive integer');
        }

        await ensureOnQianwen(page);
        await dismissLoginModal(page);
        if (startFresh) {
            await startNewChat(page);
            await dismissLoginModal(page);
        }
        await setFeatureToggle(page, 'image', true);
        await page.wait(0.5);

        const send = await sendMessage(page, prompt);

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Provide the prompt: qwen image --prompt "a red fox in snow".
  2. Check you're using the correct kwarg name ('prompt', not 'text'/'query').
  3. In scripts, guard before calling: const p = String(kwargs.prompt||'').trim(); if (!p) fail early with a clear message.
  4. Quote the prompt in the shell so multi-word text isn't split/dropped.

Example fix

// before
qwen image --text "a cat"   # wrong kwarg -> prompt missing
// after
qwen image --prompt "a cat"
Defensive patterns

Strategy: validation

Validate before calling

const prompt = String(kwargs.prompt || '').trim();
if (!prompt) throw new Error('prompt is required: pass --prompt "<text>"');

Type guard

function hasPrompt(kwargs) {
  return typeof kwargs.prompt === 'string' && kwargs.prompt.trim().length > 0;
}

Try / catch

try {
  await qwenImage({ prompt });
} catch (e) {
  if (e instanceof ArgumentError && /prompt is required/.test(e.message)) {
    throw new UsageError('Usage: qwen image --prompt "<description>" [--op dir] [--timeout 180]');
  } else throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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').

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/46c127797460e70c. Report an issue: GitHub.