jackwener/OpenCLI · error · ArgumentError
Jike search query cannot be empty
Error message
Jike search query cannot be empty
What it means
The jike search CLI trims the required positional query argument and throws ArgumentError if the result is an empty string, because the Jike search API cannot be meaningfully called without keywords. This is an input validation error raised before any network activity.
Source
Thrown at clis/jike/search.js:87
throw new CommandExecutionError(`Jike search pagination exceeded ${MAX_PAGES} pages before satisfying --limit`);
}
cli({
site: 'jike',
name: 'search',
access: 'read',
description: '搜索即刻帖子',
domain: 'web.okjike.com',
strategy: Strategy.COOKIE,
browser: true,
args: [
{ name: 'query', type: 'string', required: true, positional: true, help: '即刻搜索关键词' },
{ name: 'limit', type: 'int', default: DEFAULT_LIMIT },
],
columns: ['id', 'author', 'content', 'likes', 'comments', 'time', 'url'],
func: async (page, kwargs) => {
const keyword = String(kwargs.query || '').trim();
if (!keyword) throw new ArgumentError('Jike search query cannot be empty');
const limit = normalizeJikeLimit(kwargs.limit, DEFAULT_LIMIT);
await page.goto(`https://web.okjike.com/search?q=${encodeURIComponent(keyword)}`);
await requireJikeIdentity(page);
return searchPosts(page, keyword, limit);
},
});
View on GitHub (pinned to 49907e53dc)
Solutions
- Pass a non-empty keyword: opencli jike search "your query".
- Trim-check your script variable before invoking the command.
- If the empty value comes from a config/env variable, fix that source value.
Example fix
// before
const keyword = String(kwargs.query || '').trim();
if (!keyword) throw new ArgumentError('Jike search query cannot be empty');
// after: caller validates first
const q = (process.argv[2] || '').trim();
if (!q) { console.error('usage: jike-search <query>'); process.exit(1); }
await runCli(['jike', 'search', q]); Defensive patterns
Strategy: validation
Validate before calling
const q = String(rawQuery ?? '').trim();
if (!q) { console.error('jike search: query cannot be empty'); process.exit(2); } Prevention
- Always trim and check the query before invoking the CLI.
- Quote positional args in shell scripts to avoid empty binding.
- Fail fast in wrappers when the query variable is empty.
When it happens
Trigger: Running the command with an empty string query, a whitespace-only query (' '), or quoting mistakes where the positional arg binds to nothing (kwargs.query undefined -> String(undefined||'') === '').
Common situations: Shell quoting errors (empty '' argument); variables interpolating to empty values in scripts; trailing whitespace the user assumes is valid; forgetting the positional argument in a non-interactive pipeline.
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
- facebook marketplace-inbox --limit must be a positive intege
- Argument "content" is required.
- --limit must be a positive integer
- --limit must be an integer between 1 and ${MAX_LIMIT}
- ${label} is required
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/8e7a7615ef506dc6.
Report an issue: GitHub.