jackwener/OpenCLI · error · ArgumentError

--section requires --board

Error message

--section requires --board

What it means

Thrown in clis/pinterest/save.js:24 when a repin (save) specifies --section without --board. A section exists only within a board, so the command cannot determine which board's section to use and rejects the arguments before any API interaction.

Source

Thrown at clis/pinterest/save.js:24

cli({
  site: 'pinterest',
  name: 'save',
  access: 'write',
  description: 'Save a pin to your profile or a board',
  domain: 'www.pinterest.com',
  strategy: Strategy.COOKIE,
  args: [
    { name: 'pin', type: 'string', positional: true, required: true, help: 'Pin id or pin URL to repin, e.g. 1234567890123456' },
    { name: 'board', type: 'string', help: 'Target board: <username>/<slug>, board URL, or board id (omit to save to your profile)' },
    { name: 'section', type: 'string', default: '', help: 'Optional board section id or slug (requires --board)' },
  ],
  columns: ['pinId', 'sourcePinId', 'board', 'url'],
  func: async (page, kwargs) => {
    const sourcePinId = parsePinId(kwargs.pin);
    const boardRef = String(kwargs.board ?? '').trim();
    const section = String(kwargs.section ?? '').trim();
    if (section && !boardRef) {
      throw new ArgumentError('--section requires --board', 'Sections belong to a board, so pass --board too');
    }

    const options = { pin_id: sourcePinId };
    let sourceUrl = '/';
    let sectionId = '';

    if (boardRef) {
      const { username, slug, path, board } = await resolveBoardTarget(page, boardRef);
      await page.goto(`${PINTEREST_BASE}${path}`);

      const { boardId } = await resolveBoardId(page, username, slug, path, board);
      options.board_id = boardId;
      sourceUrl = path;
      // Validate --section before repinning, so a bad value fails before anything is created.
      if (section) sectionId = (await resolveSection(page, options.board_id, section, path)).sectionId;
    } else {
      // No board given: Pinterest routes a boardless repin to the profile's Quick Saves board.
      await page.goto(`${PINTEREST_BASE}/`);

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Pass both flags: `save --pin <id> --board <user>/<slug> --section <section>`
  2. Resolve the section's parent board and pass it explicitly — sections are never global
  3. If you meant to save to the board generally, drop --section or pick a valid section of the given board

Example fix

// before
$ opencli pinterest save --pin 999 --section inspiration
// after
$ opencli pinterest save --pin 999 --board me/inspo --section inspiration
Defensive patterns

Strategy: validation

Validate before calling

if (section && !board) {
  throw new Error('save: --section requires --board (sections belong to a board)');
}

Try / catch

try {
  await run(['save', '--pin', pinId, '--board', board, '--section', section]);
} catch (e) {
  if (/--section requires --board/.test(e.message)) {
    throw new Error('Provide the section\'s parent board via --board');
  }
  throw e;
}

Prevention

When it happens

Trigger: `save --pin <sourcePinId> --section <name-or-id>` with no --board flag, making `section` truthy while `boardRef` is empty.

Common situations: Assuming the source pin's original board implies the section; partial flag forwarding from scripts; documentation examples trimmed down that dropped --board.

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/40344b8d38a56af2. Report an issue: GitHub.