jackwener/OpenCLI · warning · ArgumentError
Refusing to delete section
Error message
Refusing to delete section "${title || sectionId}" without --confirm What it means
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.
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
Example fix
// before
await cli.run(`pinterest board-section-delete ${board} --section "${section}"`);
// after
const args = [`--section "${section}"`];
if (process.env.FORCE_DELETE === '1') args.push('--confirm');
await cli.run(`pinterest board-section-delete ${board} ${args.join(' ')}`); Defensive patterns
Strategy: validation
Validate before calling
if (kwargs.confirm !== true) {
throw new Error('re-run with --confirm to delete');
} Type guard
function isConfirmed(kwargs) {
return kwargs.confirm === true;
} Try / catch
try {
await boardSectionDelete({ board, section, confirm });
} catch (err) {
if (err instanceof ArgumentError && /without --confirm/.test(err.message)) {
const name = err.message.match(/"([^"]+)"/)?.[1];
const ok = await promptYesNo(`Delete section ${name}?`);
if (ok) return boardSectionDelete({ board, section, confirm: true });
}
throw err;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Board has no sections, so --section
- board is required
- Board returned an unusable url
- board " / " has no sections
- Could not resolve board
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/a13d31e23bf1407f.
Report an issue: GitHub.
Appendix: source
Thrown at clis/pinterest/board-section-delete.js:32
{ 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,
'ApiResource',
{ url: `/v3/board/sections/${sectionId}/`, data: {} },
path,
'delete',
);
return [{ sectionId, board: `${username}/${slug}`, deleted: true }];
},
});
View on GitHub (pinned to 49907e53dc)