jackwener/OpenCLI · error · ArgumentError

query is required

Error message

query is required

What it means

The pinterest search-pins CLI command requires a positional 'query' argument. It stringifies, trims, and rejects empty values with ArgumentError before building the /search/pins/?q= URL, because a blank keyword cannot produce a valid Pinterest search.

Source

Thrown at clis/pinterest/search-pins.js:23

const DEFAULT_LIMIT = 25;
const MAX_LIMIT = 100;

cli({
  site: 'pinterest',
  name: 'search-pins',
  access: 'read',
  description: 'Search pins 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 pins (max ${MAX_LIMIT})` },
  ],
  columns: ['pinId', 'title', 'description', 'pinner', 'board', 'imageUrl', '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/pins/?q=${encodeURIComponent(query)}`;

    await page.goto(`${PINTEREST_BASE}${sourceUrl}`);

    const rows = await collectPins(page, {
      resource: 'BaseSearchResource',
      baseOptions: { query, scope: 'pins', appliedProductFilters: '---', auto_correction_disabled: false },
      sourceUrl,
      limit,
      pageSize: DEFAULT_PAGE_SIZE,
    });

    if (rows.length === 0) {
      throw new EmptyResultError('pinterest search-pins', `no pins found for "${query}"`);
    }
    return rows;

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Provide the keyword positionally: pinterest search-pins "meal prep"
  2. Audit the calling script/wrapper to ensure it forwards arguments (use "$@")
  3. Set or export the variable feeding the query before running the command

Example fix

// before
pinterest search-pins --limit 5      // no positional query
// after
pinterest search-pins "meal prep" --limit 5
Defensive patterns

Strategy: validation

Validate before calling

const query = process.argv[2] ?? '';
if (!query.trim()) { console.error('query is required'); process.exit(2); }

Type guard

const isNonEmptyString = (v) => typeof v === 'string' && v.trim().length > 0;

Prevention

When it happens

Trigger: Invoking search-pins with no positional argument, an empty string, or whitespace only, so String(kwargs.query ?? '').trim() equals ''.

Common situations: Forgetting the keyword after flags (pinterest search-pins --limit 10), an env/config variable that is unset, or a wrapper script that fails to forward its own arguments.

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


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/10fb49d6547211a1. Report an issue: GitHub.