{"record":{"id":"b7ffdb31012e662f","repo":"jackwener/OpenCLI","slug":"section-is-required","errorCode":null,"errorMessage":"section is required","messagePattern":"section is required","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/pinterest/board-section-delete.js","lineNumber":22,"sourceCode":"import { PINTEREST_BASE, resolveBoardTarget, pinterestResourceFetch, resolveBoardId, resolveSection } from './utils.js';\n\ncli({\n  site: 'pinterest',\n  name: 'board-section-delete',\n  access: 'write',\n  description: 'Delete a section from 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: 'section', type: 'string', required: true, help: 'Section id or slug (from `board-sections`)' },\n    { name: 'confirm', type: 'bool', default: false, help: 'Actually delete — without it nothing is removed' },\n  ],\n  columns: ['sectionId', 'board', 'deleted'],\n  func: async (page, kwargs) => {\n    const { username, slug, path, board: preloadedBoard } = await resolveBoardTarget(page, kwargs.board);\n    const section = String(kwargs.section ?? '').trim();\n    if (!section) throw new ArgumentError('section is required', 'List sections with `pinterest board-sections <board>`');\n\n    await page.goto(`${PINTEREST_BASE}${path}`);\n    const { boardId } = await resolveBoardId(page, username, slug, path, preloadedBoard);\n    // Resolve before the gate so the preview names the section that would actually be deleted.\n    const { sectionId, title } = await resolveSection(page, boardId, section, path);\n\n    // Deleting a section returns its pins to the board rather than destroying them,\n    // but it is still not undoable, so keep the same --confirm gate as the other deletes.\n    if (kwargs.confirm !== true) {\n      throw new ArgumentError(\n        `Refusing to delete section \"${title || sectionId}\" without --confirm`,\n        'Re-run with --confirm once you are sure',\n      );\n    }\n\n    // BoardSectionResource only implements `create`; deletes go through the v3 API proxy.\n    await pinterestResourceFetch(\n      page,","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/pinterest/board-section-delete.js#L4-L40","documentation":"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.","triggerScenarios":"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\"`.","commonSituations":"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.","solutions":["Pass the section name or id: `pinterest board-section-delete <board> --section \"My Section\"`","Run `pinterest board-sections <board>` first to list valid section identifiers and copy one exactly","Check the shell/script variable feeding `--section` is set and non-blank","Catch ArgumentError in wrappers and surface the 'section is required' hint to the end user"],"exampleFix":"// before\nawait cli.run(`pinterest board-section-delete ${board} --section \"${section}\"`);\n// after\nif (!section || !section.trim()) throw new Error('set SECTION before deleting');\nawait cli.run(`pinterest board-section-delete ${board} --section \"${section.trim()}\"`);","handlingStrategy":"validation","validationCode":"const section = String(kwargs.section ?? '').trim();\nif (!section) throw new Error('section is required — run `pinterest board-sections <board>` to list');","typeGuard":"function hasSection(kwargs) {\n  return typeof kwargs.section === 'string' && kwargs.section.trim().length > 0;\n}","tryCatchPattern":"try {\n  await boardSectionDelete({ board, section });\n} catch (err) {\n  if (err instanceof ArgumentError && /section is required/.test(err.message)) {\n    console.error('Pass --section with a name/id from `pinterest board-sections`');\n  } else throw err;\n}","preventionTips":["List sections with board-sections before deleting and pass an exact name/id","Guard shell variables: [ -n \"$SECTION\" ] || exit 1","Validate section selection upstream in UIs/wrappers before calling delete","Trim inputs; whitespace-only section names are rejected"],"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"}