jackwener/OpenCLI · error · ArgumentError

section is required

Error message

section is required

What it means

This ArgumentError is thrown by `pinterest board-section-delete` when the required `section` kwarg is missing, empty, or whitespace-only. The command trims `String(kwargs.section ?? '')` and rejects falsy values before navigating to the board, so no network work happens. The error's second argument points the user at `pinterest board-sections <board>` to discover valid section names/ids.

Source

Thrown at clis/pinterest/board-section-delete.js:22

import { PINTEREST_BASE, resolveBoardTarget, pinterestResourceFetch, resolveBoardId, resolveSection } from './utils.js';

cli({
  site: 'pinterest',
  name: 'board-section-delete',
  access: 'write',
  description: 'Delete a section from one of your boards',
  domain: 'www.pinterest.com',
  strategy: Strategy.COOKIE,
  args: [
    { name: 'board', type: 'string', positional: true, required: true, help: '<username>/<slug>, a board URL, or a numeric board id, e.g. janedoe/my-board' },
    { name: 'section', type: 'string', required: true, help: 'Section id or slug (from `board-sections`)' },
    { name: 'confirm', type: 'bool', default: false, help: 'Actually delete — without it nothing is removed' },
  ],
  columns: ['sectionId', 'board', 'deleted'],
  func: async (page, kwargs) => {
    const { username, slug, path, board: preloadedBoard } = await resolveBoardTarget(page, kwargs.board);
    const section = String(kwargs.section ?? '').trim();
    if (!section) throw new ArgumentError('section is required', 'List sections with `pinterest board-sections <board>`');

    await page.goto(`${PINTEREST_BASE}${path}`);
    const { boardId } = await resolveBoardId(page, username, slug, path, preloadedBoard);
    // Resolve before the gate so the preview names the section that would actually be deleted.
    const { sectionId, title } = await resolveSection(page, boardId, section, path);

    // Deleting a section returns its pins to the board rather than destroying them,
    // but it is still not undoable, so keep the same --confirm gate as the other deletes.
    if (kwargs.confirm !== true) {
      throw new ArgumentError(
        `Refusing to delete section "${title || sectionId}" without --confirm`,
        'Re-run with --confirm once you are sure',
      );
    }

    // BoardSectionResource only implements `create`; deletes go through the v3 API proxy.
    await pinterestResourceFetch(
      page,

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Pass the section name or id: `pinterest board-section-delete <board> --section "My Section"`
  2. Run `pinterest board-sections <board>` first to list valid section identifiers and copy one exactly
  3. Check the shell/script variable feeding `--section` is set and non-blank
  4. Catch ArgumentError in wrappers and surface the 'section is required' hint to the end user

Example fix

// before
await cli.run(`pinterest board-section-delete ${board} --section "${section}"`);
// after
if (!section || !section.trim()) throw new Error('set SECTION before deleting');
await cli.run(`pinterest board-section-delete ${board} --section "${section.trim()}"`);
Defensive patterns

Strategy: validation

Validate before calling

const section = String(kwargs.section ?? '').trim();
if (!section) throw new Error('section is required — run `pinterest board-sections <board>` to list');

Type guard

function hasSection(kwargs) {
  return typeof kwargs.section === 'string' && kwargs.section.trim().length > 0;
}

Try / catch

try {
  await boardSectionDelete({ board, section });
} catch (err) {
  if (err instanceof ArgumentError && /section is required/.test(err.message)) {
    console.error('Pass --section with a name/id from `pinterest board-sections`');
  } else throw err;
}

Prevention

When it happens

Trigger: Running `pinterest board-section-delete <board>` without `--section`; passing `--section ""` or `--section " "`; invoking func programmatically with kwargs lacking the section key; an unset shell variable interpolated into `--section "$SECTION"`.

Common situations: Automation scripts where the section variable was never set; users confusing the board name with the section name; passing an empty id because an upstream lookup step failed.

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