{"record":{"id":"1522607b2e668ae4","repo":"jackwener/OpenCLI","slug":"board-has-no-sections-so-section-wanted-ca","errorCode":null,"errorMessage":"Board has no sections, so --section \"${wanted}\" cannot be used","messagePattern":"Board has no sections, so --section \"(.+?)\" cannot be used","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/pinterest/utils.js","lineNumber":323,"sourceCode":"  const parts = decodeSegment(url).split('/').filter(Boolean);\n  if (parts.length < 2) {\n    throw new CommandExecutionError(`Board ${trimmed} returned an unusable url: ${url}`);\n  }\n  // Hand the fetched board back so callers do not re-request what we already have.\n  return { username: parts[0], slug: parts[1], path: `/${parts[0]}/${parts[1]}/`, board };\n}\n\n/**\n * Resolve a --section value against the board's real sections, accepting an id or a slug.\n * Pinterest ignores an unknown section silently, so an unmatched value must fail here.\n * Returns { sectionId, title, slug }.\n */\nexport async function resolveSection(page, boardId, sectionValue, sourceUrl) {\n  const wanted = String(sectionValue ?? '').trim();\n  const { results } = await pinterestResourceFetch(page, 'BoardSectionsResource', { board_id: String(boardId) }, sourceUrl);\n  const sections = results.filter((section) => section && section.id);\n  if (sections.length === 0) {\n    throw new ArgumentError(`Board has no sections, so --section \"${wanted}\" cannot be used`, 'Create one first with `opencli pinterest board-section-create`');\n  }\n  const folded = normalizeForMatch(wanted);\n  const match = sections.find((section) => String(section.id) === wanted)\n    || sections.find((section) => normalizeForMatch(section.slug) === folded);\n  if (!match) {\n    const available = sections.map((section) => `${section.slug || '(no slug)'} (${section.id})`).join(', ');\n    throw new ArgumentError(`No section matching \"${wanted}\" on this board`, `Pass a section slug or id — available: ${available}`);\n  }\n  return { sectionId: String(match.id), title: (match.title || '').trim(), slug: match.slug || '' };\n}\n\n/**\n * Move an existing pin into a board section.\n * The create endpoints (PinResource/create, RepinResource/create) accept a section key, answer\n * HTTP 200, and file the pin at the board root anyway — only PinResource/update honours it. So\n * callers that create a pin have to follow up with this second request.\n */\nexport async function movePinToSection(page, pinId, boardId, sectionId, sourceUrl) {","sourceCodeStart":305,"sourceCodeEnd":341,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/pinterest/utils.js#L305-L341","documentation":"resolveSection fetches a board's sections via BoardSectionsResource before matching a --section value. If the board has zero sections at all, no --section value can match, so it throws this ArgumentError telling the user to create a section first.","triggerScenarios":"Running a command with `--section <name>` against a board that has never had any board sections created (BoardSectionsResource returns an empty results list).","commonSituations":"Scripting a pin-to-section move against a fresh/default board; assuming a board has sections because the UI shows folders elsewhere; wrong board id passed so a different, section-less board is queried.","solutions":["Create a section with `opencli pinterest board-section-create` and retry.","Drop the `--section` flag to place the pin at the board root instead.","Verify you targeted the intended board — run `opencli pinterest board-sections <board>` to list its sections."],"exampleFix":"// before\nopencli pinterest pin-create --board someuser/recipes --section Desserts ...\n// after\nopencli pinterest board-section-create --board someuser/recipes --title Desserts\nopencli pinterest pin-create --board someuser/recipes --section Desserts ...","handlingStrategy":"validation","validationCode":"const sections = await runCmd(['opencli', 'pinterest', 'board-sections', board]);\nif (!sections.length && wantedSection) {\n  await runCmd(['opencli', 'pinterest', 'board-section-create', '--board', board, '--title', wantedSection]);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await pinToBoard({ board, section });\n} catch (err) {\n  if (String(err.message).includes('Board has no sections')) {\n    await pinToBoard({ board }); // place at board root instead\n  } else throw err;\n}","preventionTips":["Call `board-sections <board>` before any scripted pin-to-section operation.","Create required sections idempotently (create-if-missing) at script start.","Make --section optional in your scripts and fall back to board root."],"tags":["pinterest","argument","section","empty-list"],"backgroundTag":"resource-not-found","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}