jackwener/OpenCLI · error · ArgumentError
query is required
Error message
query is required
What it means
The pinterest search-boards CLI command requires a positional 'query' argument. The command normalizes the argument to a string, trims it, and throws ArgumentError when the result is empty. This guards against sending Pinterest a search URL with an empty q= parameter, which would never return meaningful results.
Source
Thrown at clis/pinterest/search-boards.js:23
const DEFAULT_LIMIT = 25;
const MAX_LIMIT = 100;
cli({
site: 'pinterest',
name: 'search-boards',
access: 'read',
description: 'Search for boards on Pinterest',
domain: 'www.pinterest.com',
strategy: Strategy.COOKIE,
args: [
{ name: 'query', type: 'string', positional: true, required: true, help: 'Search keyword' },
{ name: 'limit', type: 'int', default: DEFAULT_LIMIT, help: `Number of boards (max ${MAX_LIMIT})` },
],
columns: ['boardId', 'name', 'pinCount', 'owner', 'description', 'url'],
func: async (page, kwargs) => {
const query = String(kwargs.query ?? '').trim();
if (!query) throw new ArgumentError('query is required');
const limit = requireLimit(kwargs.limit, { fallback: DEFAULT_LIMIT, max: MAX_LIMIT });
const sourceUrl = `/search/boards/?q=${encodeURIComponent(query)}`;
await page.goto(`${PINTEREST_BASE}${sourceUrl}`);
const rows = await collectResults(page, {
resource: 'BaseSearchResource',
baseOptions: { query, scope: 'boards' },
sourceUrl,
limit,
keyField: 'boardId',
pageSize: DEFAULT_PAGE_SIZE,
mapItem: (board) => {
if (!board || board.type !== 'board' || !board.id) return null;
return {
boardId: String(board.id),
name: board.name || '',
pinCount: typeof board.pin_count === 'number' ? board.pin_count : 0,View on GitHub (pinned to 49907e53dc)
Solutions
- Pass a non-empty search keyword as the first positional argument: pinterest search-boards "diy home"
- Check the shell variable you are interpolating actually has a value before invoking the command
- Quote the argument so the shell does not swallow it: pinterest search-boards "${QUERY}"
Example fix
// before pinterest search-boards $QUERY // QUERY is empty -> ArgumentError // after if [ -z "$QUERY" ]; then echo "query is required" >&2; exit 1; fi pinterest search-boards "$QUERY"
Defensive patterns
Strategy: validation
Validate before calling
const query = typeof argv.query === 'string' ? argv.query.trim() : '';
if (!query) { console.error('usage: pinterest search-boards <query>'); process.exit(2); } Type guard
const isNonEmptyString = (v) => typeof v === 'string' && v.trim().length > 0;
Prevention
- Always quote positional search arguments in shell scripts
- Validate shell variables with ${VAR:?msg} before invoking the CLI
- Check --help to confirm which arguments are positional and required
When it happens
Trigger: Calling `pinterest search-boards` with no positional argument, with an empty string (''), or with a whitespace-only value (' '), such that kwargs.query is undefined or trims to ''.
Common situations: Shell variables that expand to empty (e.g. QUERY=""; pinterest search-boards "$QUERY"), quoting mistakes that drop the argument, scripts where the user skipped a prompt, or piping an empty stdin value into the command.
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
- keyword must not be empty
- <from> station must not be empty
- <to> station must not be empty
- who 不能为空
- key is required
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/405d17f95c8c605b.
Report an issue: GitHub.