jackwener/OpenCLI · error · ArgumentError
query
Error message
query
What it means
Thrown by the qoder search (query) command when the required positional 'query' argument is missing or empty after trimming. The library validates arguments up front and raises ArgumentError('query', 'is required') rather than opening the search palette with a blank string. This is an input-validation error, not a UI failure.
Source
Thrown at clis/qoder/ui.js:75
});
// -------- search --------
cli({
site: 'qoder',
name: 'search',
access: 'read',
description: 'Open Qoder Search palette (⌘P), type a query, return matched options.',
domain: 'localhost',
strategy: Strategy.UI,
browser: true,
args: [
{ name: 'query', positional: true, required: true, help: 'Search text' },
{ name: 'limit', type: 'int', required: false, default: 20 },
],
columns: ['Index', 'Item'],
func: async (page, kwargs) => {
const query = String(kwargs?.query || '').trim();
if (!query) throw new ArgumentError('query', 'is required');
const limit = parsePositiveInt(kwargs?.limit, 20, '--limit');
const openRes = await evaluateQoder(page, clickByTextScript(['Search']));
if (!openRes?.ok) throw new CommandExecutionError(openRes?.reason || 'search open failed', '');
await page.wait(0.5);
// Type into the visible input (usually the most-recently mounted one).
const fillRes = await evaluateQoder(page, `(() => {
${IS_VISIBLE_JS}
const inputs = Array.from(document.querySelectorAll('input[type="text"], input[type="search"], input:not([type])')).filter(isVisible);
const input = inputs[inputs.length - 1];
if (!input) return { ok: false, reason: 'No input visible.' };
const setter = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, 'value').set;
setter.call(input, ${JSON.stringify(query)});
input.dispatchEvent(new Event('input', { bubbles: true }));
input.dispatchEvent(new Event('change', { bubbles: true }));
return { ok: true };
})()`);
if (!fillRes?.ok) throw new CommandExecutionError(fillRes?.reason || 'search type failed', '');
await page.wait(0.8);View on GitHub (pinned to 49907e53dc)
Solutions
- Pass the search text as the positional argument, e.g. qoder search "error handling".
- Quote the argument so the shell doesn't split or drop it.
- Check the upstream variable is non-empty before invoking the command.
Example fix
// before QUERY=""; qoder search $QUERY // after QUERY="error handling"; [ -n "$QUERY" ] && qoder search "$QUERY"
Defensive patterns
Strategy: validation
Validate before calling
const query = String(process.argv[2] || '').trim();
if (!query) { console.error('usage: qoder search <query>'); process.exit(2); } Try / catch
try {
await search(page, query);
} catch (e) {
if (e instanceof ArgumentError && e.message.includes('query')) {
console.error('Pass a non-empty positional search text');
} else throw e;
} Prevention
- Always quote the positional query in shell scripts.
- Validate CLI variables are non-empty before invocation.
- Remember query is positional, not a --query flag.
- Trim whitespace-only inputs before calling.
When it happens
Trigger: Calling the search command without the positional query argument; passing an empty string or whitespace-only string; passing a non-string value that String()s to empty; a wrapper script dropping the argument.
Common situations: Shell quoting mistakes that swallow the argument; CI scripts with empty variables interpolated into the command; users omitting the positional because they expected a --query flag.
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
- tid must be a numeric thread id
- --from and --to must differ (got ${fromCity})
- --from and --to must differ (got ${fromCode})
- --from and --to must differ (got ${fromName})
- Unknown --since "${sinceKey}". Valid: ${Object.keys(SINCE).j
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/bcf4aa1aa336c697.
Report an issue: GitHub.