jackwener/OpenCLI · error · ArgumentError

board is required

Error message

board is required

What it means

resolveBoardTarget requires a non-empty board argument. Empty, null, or whitespace-only input throws ArgumentError, because there is no way to identify which board to operate on.

Source

Thrown at clis/pinterest/utils.js:282

export async function resolveBoardId(page, username, slug, path, preloaded = null) {
  const board = preloaded && preloaded.id
    ? preloaded
    : (await pinterestResourceFetch(page, 'BoardResource', { username, slug, field_set_key: 'detailed' }, path)).data;
  const boardId = board && board.id;
  if (!boardId) {
    throw new CommandExecutionError(`Could not resolve board "${username}/${slug}" (does it exist and do you own it?)`);
  }
  return { boardId: String(boardId), board };
}

/**
 * Resolve a board argument to { username, slug, path }, accepting a full board URL,
 * <username>/<slug>, or a numeric board id (which BoardResource can look up directly).
 * Display names are deliberately not accepted: a name cannot say whose board it is.
 */
export async function resolveBoardTarget(page, raw) {
  const trimmed = String(raw ?? '').trim();
  if (!trimmed) throw new ArgumentError('board is required', 'Pass <username>/<slug>, a board URL, or a numeric board id');

  const direct = tryParseBoardRef(trimmed);
  if (direct) return { ...direct, board: null };

  if (!/^\d+$/.test(trimmed)) {
    throw new ArgumentError(
      `Not a board reference: "${trimmed}"`,
      'Expected <username>/<slug>, a board URL, or a numeric board id (from `board-pins`/`user-boards`)',
    );
  }

  await page.goto(`${PINTEREST_BASE}/`);
  const { data: board } = await pinterestResourceFetch(
    page,
    'BoardResource',
    { board_id: trimmed, field_set_key: 'detailed' },
    '/',
  );

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Pass a board argument: <username>/<slug>, a board URL, or a numeric board id
  2. Check the shell/config variable actually holds a value before calling
  3. On CLI, include the --board flag with a value
  4. Run user-boards to find the correct board reference

Example fix

// before
const board = process.env.BOARD || '';
await cmd.createPin({ board, ... }); // throws
// after
if (!process.env.BOARD) throw new Error('BOARD env var required');
await cmd.createPin({ board: process.env.BOARD, ... });
Defensive patterns

Strategy: validation

Validate before calling

function requireBoardArg(v){ if (v == null || String(v).trim() === '') throw new Error('board is required: pass <username>/<slug>, a board URL, or a numeric id'); return String(v).trim(); }

Type guard

null

Try / catch

try { await cmd.createPin(args); } catch (e) { if (e instanceof ArgumentError && /board is required/.test(e.message)) { console.error('Supply --board <username>/<slug> or a board URL.'); } else throw e; }

Prevention

When it happens

Trigger: Passing an empty string, null, or undefined as the board option, e.g. { board: '' } or omitting --board on the CLI when the command requires it; a variable that failed to populate before the call.

Common situations: Shell variable unset ($BOARD empty); config file missing the board key; CLI flag typo so the flag value never binds; template interpolation producing an empty string.

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/6d085bcd837afffe. Report an issue: GitHub.