{"record":{"id":"cc74618b08d97637","repo":"mattermost-community/focalboard","slug":"at-least-one-block-is-required","errorCode":null,"errorMessage":"at least one block is required","messagePattern":"at least one block is required","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"error","filePath":"server/model/boards_and_blocks.go","lineNumber":15,"sourceCode":"package model\n\nimport (\n\t\"encoding/json\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\n\t\"github.com/mattermost/focalboard/server/utils\"\n\n\t\"github.com/mattermost/mattermost/server/public/shared/mlog\"\n)\n\nvar ErrNoBoardsInBoardsAndBlocks = errors.New(\"at least one board is required\")\nvar ErrNoBlocksInBoardsAndBlocks = errors.New(\"at least one block is required\")\nvar ErrNoTeamInBoardsAndBlocks = errors.New(\"team ID cannot be empty\")\nvar ErrBoardIDsAndPatchesMissmatchInBoardsAndBlocks = errors.New(\"board ids and patches need to match\")\nvar ErrBlockIDsAndPatchesMissmatchInBoardsAndBlocks = errors.New(\"block ids and patches need to match\")\n\ntype BlockDoesntBelongToAnyBoardErr struct {\n\tblockID string\n}\n\nfunc (e BlockDoesntBelongToAnyBoardErr) Error() string {\n\treturn fmt.Sprintf(\"block %s doesn't belong to any board\", e.blockID)\n}\n\n// BoardsAndBlocks is used to operate over boards and blocks at the\n// same time\n// swagger:model\ntype BoardsAndBlocks struct {\n\t// The boards\n\t// required: false","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/mattermost-community/focalboard/blob/a84bbb65e32edf972856b329417096ac413518e9/server/model/boards_and_blocks.go#L1-L33","documentation":"ErrNoBlocksInBoardsAndBlocks is a sentinel error in the BoardsAndBlocks model. BoardsAndBlocks.IsValid() requires at least one block, and this error reports that the payload's Blocks array is empty.","triggerScenarios":"POST /api/v2/boards-and-blocks (or BoardsAndBlocks.IsValid()) with an empty Blocks array.","commonSituations":"Import tooling uploading boards without their blocks; filtering block lists (e.g. by board membership) before submission and ending up with zero items.","solutions":["Include at least one block in the Blocks array of the payload","Validate len(blocksAndBlocks.Blocks) > 0 client-side before calling the API","Skip the call or surface a user-facing message when there is genuinely nothing to import"],"exampleFix":"// before\nawait client.importBoardsAndBlocks({boards: [board], blocks: []})\n// after\nif (payload.blocks.length > 0) {\n  await client.importBoardsAndBlocks(payload)\n}","handlingStrategy":"validation","validationCode":"if (!payload.blocks || payload.blocks.length === 0) {\n  throw new Error('at least one block is required before import')\n}","typeGuard":null,"tryCatchPattern":"try {\n  await client.importBoardsAndBlocks(payload)\n} catch (err) {\n  if (err.message?.includes('at least one block')) {\n    alert('Nothing to import: payload has no blocks')\n  } else throw err\n}","preventionTips":["Validate the payload shape before API calls","Don't drop blocks in pre-submit filtering without re-checking the result","Skip the call entirely when the collection is empty"],"tags":["go","validation","import","bad-request"],"backgroundTag":"empty-collection-validation","analyzedSha":"a84bbb65e32edf972856b329417096ac413518e9","analyzedAt":"2026-08-30T09:22:20.720Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}