jackwener/OpenCLI · error · ArgumentError
prompt is required
Error message
prompt is required
What it means
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.
Source
Thrown at clis/qwen/ask.js:41
description: 'Send a prompt to Qianwen and return the assistant reply',
domain: QIANWEN_DOMAIN,
strategy: Strategy.COOKIE,
browser: true,
siteSession: 'persistent',
navigateBefore: false,
defaultFormat: 'plain',
args: [
{ name: 'prompt', required: true, positional: true, help: 'Prompt to send to Qianwen' },
{ name: 'timeout', type: 'int', default: 120, help: 'Max seconds to wait for the response' },
{ name: 'new', type: 'boolean', default: false, help: 'Start a new chat before sending' },
{ name: 'think', type: 'boolean', default: false, help: 'Enable 深度思考 (DeepThink)' },
{ name: 'research', type: 'boolean', default: false, help: 'Enable 深度研究 (DeepResearch)' },
{ name: 'markdown', type: 'boolean', default: false, help: 'Emit assistant reply as markdown' },
],
columns: ['Role', 'Text'],
func: async (page, kwargs) => {
const prompt = String(kwargs.prompt || '').trim();
if (!prompt) throw new ArgumentError('prompt is required');
const timeout = Number(kwargs.timeout ?? 120);
if (!Number.isInteger(timeout) || timeout <= 0) {
throw new ArgumentError('timeout must be a positive integer');
}
const startFresh = normalizeBooleanFlag(kwargs.new, false);
const useThink = normalizeBooleanFlag(kwargs.think, false);
const useResearch = normalizeBooleanFlag(kwargs.research, false);
const wantMarkdown = normalizeBooleanFlag(kwargs.markdown, false);
await ensureOnQianwen(page);
await dismissLoginModal(page);
if (startFresh) {
await startNewChat(page);
await dismissLoginModal(page);
}
if (useThink) await setFeatureToggle(page, 'think', true);View on GitHub (pinned to 49907e53dc)
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.
Example fix
// before qwen ask --prompt "" --timeout 120 // after qwen ask --prompt "Summarize this repo" --timeout 120
Defensive patterns
Strategy: validation
Validate before calling
const prompt = String(process.argv.prompt || '').trim();
if (!prompt) { console.error('usage: qwen ask --prompt "..."'); process.exit(2); } Type guard
function hasPrompt(kwargs) {
return typeof kwargs.prompt === 'string' && kwargs.prompt.trim().length > 0;
} Try / catch
try {
await qwenAsk(page, { prompt });
} catch (e) {
if (e instanceof ArgumentError && /prompt/.test(e.message)) {
console.error('A non-empty --prompt is required');
} else { throw e; }
} Prevention
- Always quote --prompt values in shell scripts
- Assert prompt variables are non-empty before invoking
- Fail fast in wrappers with a usage message
When it happens
Trigger: Running `qwen ask` without --prompt, with --prompt "" or only whitespace; programmatic invocation passing kwargs without a prompt key.
Common situations: Shell quoting issues losing the argument; a script building the command with an empty variable; copy-pasting a command without the prompt value.
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
- ${label} is required
- ${label} must be a positive integer
- ${label} must be <= ${maxValue}
- dblp ${label} must be a positive integer
- dblp ${label} must be <= ${maxValue}
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/b953d6d4fdcb965f.
Report an issue: GitHub.