{"record":{"id":"9f4a853d89e146bf","repo":"jackwener/OpenCLI","slug":"section-title-is-required","errorCode":null,"errorMessage":"section title is required","messagePattern":"section title is required","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/pinterest/board-section-create.js","lineNumber":21,"sourceCode":"import { ArgumentError, CommandExecutionError } from '@jackwener/opencli/errors';\nimport { PINTEREST_BASE, resolveBoardTarget, pinterestResourceCreate, resolveBoardId } from './utils.js';\n\ncli({\n  site: 'pinterest',\n  name: 'board-section-create',\n  access: 'write',\n  description: 'Create a section inside one of your boards',\n  domain: 'www.pinterest.com',\n  strategy: Strategy.COOKIE,\n  args: [\n    { name: 'board', type: 'string', positional: true, required: true, help: '<username>/<slug>, a board URL, or a numeric board id, e.g. janedoe/my-board' },\n    { name: 'title', type: 'string', required: true, help: 'Section title' },\n  ],\n  columns: ['sectionId', 'title', 'slug', 'board', 'url'],\n  func: async (page, kwargs) => {\n    const { username, slug, path, board: preloadedBoard } = await resolveBoardTarget(page, kwargs.board);\n    const title = String(kwargs.title ?? '').trim();\n    if (!title) throw new ArgumentError('section title is required');\n\n    await page.goto(`${PINTEREST_BASE}${path}`);\n    const { boardId } = await resolveBoardId(page, username, slug, path, preloadedBoard);\n\n    // The section title goes in `name` here (a `title` key is rejected as a missing parameter).\n    const created = await pinterestResourceCreate(\n      page,\n      'BoardSectionResource',\n      { board_id: boardId, name: title },\n      path,\n    );\n    const sectionId = created && created.id;\n    if (!sectionId) {\n      throw new CommandExecutionError('Section creation did not return a section id');\n    }\n\n    return [{\n      sectionId: String(sectionId),","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/pinterest/board-section-create.js#L3-L39","documentation":"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'.","triggerScenarios":"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 ''.","commonSituations":"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.","solutions":["Pass a non-empty title: `pinterest board-section-create <board> --title \"My Section\"`","Check the script/CI variable that feeds `--title` is set and non-blank before invoking","Validate/trim the title in your wrapper code before calling the command","Catch ArgumentError and print the help line ('Section title') to guide the user"],"exampleFix":"// before\nawait cli.run(`pinterest board-section-create ${board} --title \"${title}\"`);\n// after\nif (!title || !title.trim()) throw new Error('provide a section title');\nawait cli.run(`pinterest board-section-create ${board} --title \"${title.trim()}\"`);","handlingStrategy":"validation","validationCode":"const title = String(kwargs.title ?? '').trim();\nif (!title) throw new Error('section title is required');","typeGuard":"function hasTitle(kwargs) {\n  return typeof kwargs.title === 'string' && kwargs.title.trim().length > 0;\n}","tryCatchPattern":"try {\n  await boardSectionCreate({ board, title });\n} catch (err) {\n  if (err instanceof ArgumentError && /section title is required/.test(err.message)) {\n    console.error('Usage: --title \"Section name\"');\n  } else throw err;\n}","preventionTips":["Always trim and truthy-check user-supplied titles before invoking","In shell scripts, guard: [ -n \"$TITLE\" ] || exit 1","Quote --title values to avoid shells eating empty strings","Derive a default title from context instead of leaving it blank"],"tags":["pinterest","missing-argument","validation"],"backgroundTag":"missing-required-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}