jackwener/OpenCLI · error · ArgumentError

section title is required

Error message

section title is required

What it means

This ArgumentError is thrown by `pinterest board-section-create` when the required `title` kwarg is missing, empty, or only whitespace. The command trims `String(kwargs.title ?? '')` and rejects any falsy result before making any network calls, so no board navigation or API request happens when it fires. The CLI argument is declared `required: true`, but the runtime check guards against empty strings that still satisfy 'argument present'.

Source

Thrown at clis/pinterest/board-section-create.js:21

import { ArgumentError, CommandExecutionError } from '@jackwener/opencli/errors';
import { PINTEREST_BASE, resolveBoardTarget, pinterestResourceCreate, resolveBoardId } from './utils.js';

cli({
  site: 'pinterest',
  name: 'board-section-create',
  access: 'write',
  description: 'Create a section inside 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: 'title', type: 'string', required: true, help: 'Section title' },
  ],
  columns: ['sectionId', 'title', 'slug', 'board', 'url'],
  func: async (page, kwargs) => {
    const { username, slug, path, board: preloadedBoard } = await resolveBoardTarget(page, kwargs.board);
    const title = String(kwargs.title ?? '').trim();
    if (!title) throw new ArgumentError('section title is required');

    await page.goto(`${PINTEREST_BASE}${path}`);
    const { boardId } = await resolveBoardId(page, username, slug, path, preloadedBoard);

    // The section title goes in `name` here (a `title` key is rejected as a missing parameter).
    const created = await pinterestResourceCreate(
      page,
      'BoardSectionResource',
      { board_id: boardId, name: title },
      path,
    );
    const sectionId = created && created.id;
    if (!sectionId) {
      throw new CommandExecutionError('Section creation did not return a section id');
    }

    return [{
      sectionId: String(sectionId),

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Pass a non-empty title: `pinterest board-section-create <board> --title "My Section"`
  2. Check the script/CI variable that feeds `--title` is set and non-blank before invoking
  3. Validate/trim the title in your wrapper code before calling the command
  4. Catch ArgumentError and print the help line ('Section title') to guide the user

Example fix

// before
await cli.run(`pinterest board-section-create ${board} --title "${title}"`);
// after
if (!title || !title.trim()) throw new Error('provide a section title');
await cli.run(`pinterest board-section-create ${board} --title "${title.trim()}"`);
Defensive patterns

Strategy: validation

Validate before calling

const title = String(kwargs.title ?? '').trim();
if (!title) throw new Error('section title is required');

Type guard

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

Try / catch

try {
  await boardSectionCreate({ board, title });
} catch (err) {
  if (err instanceof ArgumentError && /section title is required/.test(err.message)) {
    console.error('Usage: --title "Section name"');
  } else throw err;
}

Prevention

When it happens

Trigger: Running `pinterest board-section-create <board>` without `--title`; passing `--title ""` or `--title " "`; programmatically invoking func with `kwargs = { board: 'user/board' }` and no title key; passing null/undefined title which coerces to ''.

Common situations: Shell scripts with an unset variable (`--title "$SECTION_NAME"` where the var is empty); automation wrappers that forget the title field; copying a command template with a placeholder never filled in.

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