jackwener/OpenCLI · error · ArgumentError
query cannot be empty
Error message
query cannot be empty
What it means
ArgumentError (exit code 2, ARGUMENT / usage error) thrown by the coupang search command when the required query argument is missing, empty, or whitespace-only after trimming. The command refuses to build a search URL without a query.
Source
Thrown at clis/coupang/search.js:418
cli({
site: 'coupang',
name: 'search',
access: 'read',
description: 'Search Coupang products with logged-in browser session',
domain: 'www.coupang.com',
strategy: Strategy.COOKIE,
browser: true,
args: [
{ name: 'query', required: true, positional: true, help: 'Search keyword' },
{ name: 'page', type: 'int', default: 1, help: 'Search result page number' },
{ name: 'limit', type: 'int', default: 20, help: 'Max results (max 50)' },
{ name: 'filter', required: false, help: 'Optional search filter (currently supports: rocket)' },
],
columns: ['rank', 'product_id', 'title', 'price', 'unit_price', 'rating', 'review_count', 'rocket', 'delivery_type', 'delivery_promise', 'url'],
func: async (page, kwargs) => {
const query = String(kwargs.query || '').trim();
if (!query) {
throw new ArgumentError('query cannot be empty');
}
const pageNumber = parsePageArg(kwargs.page, 1);
const limit = parseLimitArg(kwargs.limit, 20, 50);
const filter = String(kwargs.filter || '').trim().toLowerCase();
if (filter && filter !== 'rocket') {
throw new ArgumentError(`Unsupported --filter "${filter}" (supported: rocket)`);
}
const initialPage = filter ? 1 : pageNumber;
const url = `https://www.coupang.com/np/search?q=${encodeURIComponent(query)}&channel=user&page=${initialPage}`;
await page.goto(url).catch((error) => {
throw new CommandExecutionError(`coupang search navigation failed: ${error?.message || error}`);
});
if (filter) {
const filterResult = await page.evaluate(buildApplyFilterEvaluate(filter)).catch((error) => {
throw new CommandExecutionError(`coupang search filter evaluation failed: ${error?.message || error}`);
});
if (!filterResult?.ok) {
throw new EmptyResultError('coupang search', `Filter "${filter}" was not available on the current page; try without --filter or wait for Coupang to render the filter bar.`);View on GitHub (pinned to 49907e53dc)
Solutions
- Pass a non-empty query: opencli coupang search "wireless keyboard".
- Check that the shell variable feeding the argument is set and non-blank.
- Quote the query so spaces/special characters don't split or drop arguments.
- Print/verify kwargs in your wrapper script before invoking the command.
Example fix
// before opencli coupang search "$QUERY" # QUERY is empty // after [ -n "$QUERY" ] && opencli coupang search "$QUERY"
Defensive patterns
Strategy: validation
Validate before calling
function validateSearchQuery(query) {
const q = String(query ?? '').trim();
if (!q) throw new Error('query cannot be empty');
return q;
}
// usage: run('coupang search', { query: validateSearchQuery(userInput) }) Type guard
function hasQuery(kwargs) { return typeof kwargs?.query === 'string' && kwargs.query.trim().length > 0; } Try / catch
try {
return await run('coupang search', { query });
} catch (err) {
if (err?.code === 'ARGUMENT' && /query cannot be empty/.test(err.message)) {
console.error('Provide a non-empty search query, e.g. opencli coupang search "keyboard"');
process.exit(2);
}
throw err;
} Prevention
- Trim and check the query before invoking, especially when it comes from a shell variable.
- Quote queries with spaces in the shell.
- Use "${VAR:?msg}" in bash to fail fast on unset/empty variables.
- Validate user input in wrapper scripts before calling the CLI.
When it happens
Trigger: `opencli coupang search` with no query, an empty string, or only whitespace: e.g. `opencli coupang search ""` or omitting the positional/query kwarg entirely.
Common situations: Shell variable holding the query is empty/unset (e.g. $QUERY interpolated to nothing); quoting mistake causing the arg to be swallowed; scripting with a value that trims to nothing; forgetting the --query/positional form of the argument.
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
- Unsupported --filter
- bbc topic "${args.topic}" is not supported
- bbc ${label} must be a positive integer
- bbc ${label} must be <= ${maxValue}
- ARGUMENT
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/ebe4b2fe94794dae.
Report an issue: GitHub.