{"record":{"id":"a13d31e23bf1407f","repo":"jackwener/OpenCLI","slug":"refusing-to-delete-section-title-sectionid","errorCode":null,"errorMessage":"Refusing to delete section \"${title || sectionId}\" without --confirm","messagePattern":"Refusing to delete section \"(.+?)\" without --confirm","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"warning","filePath":"clis/pinterest/board-section-delete.js","lineNumber":32,"sourceCode":"    { 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,\n      'ApiResource',\n      { url: `/v3/board/sections/${sectionId}/`, data: {} },\n      path,\n      'delete',\n    );\n\n    return [{ sectionId, board: `${username}/${slug}`, deleted: true }];\n  },\n});\n","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/pinterest/board-section-delete.js#L14-L50","documentation":"This ArgumentError is a destructive-action safety gate: `pinterest board-section-delete` refuses to delete unless `--confirm` (kwargs.confirm === true) was passed. The section is resolved first (line 32) so the message names the exact section (`title || sectionId`) that would be deleted, giving an accurate preview before the user opts in. This mirrors the confirm gate used by other delete commands in this CLI family.","triggerScenarios":"Running `pinterest board-section-delete <board> --section \"X\"` without `--confirm`; passing `--confirm false` programmatically (kwargs.confirm !== true); forgetting the flag in a script migrated from a non-gated version; typos like `--confirmed` that leave confirm unset.","commonSituations":"Interactive users previewing what a delete would remove (the intended flow); CI jobs that must add `--confirm` explicitly to delete; wrappers that build kwargs and never set confirm: true.","solutions":["Re-run with the flag once sure: `pinterest board-section-delete <board> --section \"X\" --confirm`","In programmatic use set kwargs.confirm to the boolean true (not a truthy string)","Detect this ArgumentError by its message and prompt the user for confirmation before retrying with confirm: true","Use the command without --confirm intentionally as a dry-run to see which section would be deleted"],"exampleFix":"// before\nawait cli.run(`pinterest board-section-delete ${board} --section \"${section}\"`);\n// after\nconst args = [`--section \"${section}\"`];\nif (process.env.FORCE_DELETE === '1') args.push('--confirm');\nawait cli.run(`pinterest board-section-delete ${board} ${args.join(' ')}`);","handlingStrategy":"validation","validationCode":"if (kwargs.confirm !== true) {\n  throw new Error('re-run with --confirm to delete');\n}","typeGuard":"function isConfirmed(kwargs) {\n  return kwargs.confirm === true;\n}","tryCatchPattern":"try {\n  await boardSectionDelete({ board, section, confirm });\n} catch (err) {\n  if (err instanceof ArgumentError && /without --confirm/.test(err.message)) {\n    const name = err.message.match(/\"([^\"]+)\"/)?.[1];\n    const ok = await promptYesNo(`Delete section ${name}?`);\n    if (ok) return boardSectionDelete({ board, section, confirm: true });\n  }\n  throw err;\n}","preventionTips":["Treat a run without --confirm as a free dry-run/preview first","In CI, require an explicit env like FORCE_DELETE=1 to add --confirm","Always pass the boolean true, not a truthy string, for confirm","Add a confirmation prompt in interactive wrappers before retrying with --confirm"],"tags":["pinterest","safety-gate","confirmation-required","destructive-operation"],"backgroundTag":"missing-confirmation-flag","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}