mattermost-community/focalboard · error

at least one block is required

Error message

at least one block is required

What it means

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.

Solutions

  1. Include at least one block in the Blocks array of the payload
  2. Validate len(blocksAndBlocks.Blocks) > 0 client-side before calling the API
  3. Skip the call or surface a user-facing message when there is genuinely nothing to import

Example fix

// before
await client.importBoardsAndBlocks({boards: [board], blocks: []})
// after
if (payload.blocks.length > 0) {
  await client.importBoardsAndBlocks(payload)
}
Defensive patterns

Strategy: validation

Validate before calling

if (!payload.blocks || payload.blocks.length === 0) {
  throw new Error('at least one block is required before import')
}

Try / catch

try {
  await client.importBoardsAndBlocks(payload)
} catch (err) {
  if (err.message?.includes('at least one block')) {
    alert('Nothing to import: payload has no blocks')
  } else throw err
}

Prevention

When it happens

Trigger: POST /api/v2/boards-and-blocks (or BoardsAndBlocks.IsValid()) with an empty Blocks array.

Common situations: Import tooling uploading boards without their blocks; filtering block lists (e.g. by board membership) before submission and ending up with zero items.

Related errors


AI-assisted analysis of mattermost-community/focalboard@a84bbb65e3 (2026-08-30). Data as JSON: /api/errors/cc74618b08d97637. Report an issue: GitHub.

Appendix: source

Thrown at server/model/boards_and_blocks.go:15

package model

import (
	"encoding/json"
	"errors"
	"fmt"
	"io"

	"github.com/mattermost/focalboard/server/utils"

	"github.com/mattermost/mattermost/server/public/shared/mlog"
)

var ErrNoBoardsInBoardsAndBlocks = errors.New("at least one board is required")
var ErrNoBlocksInBoardsAndBlocks = errors.New("at least one block is required")
var ErrNoTeamInBoardsAndBlocks = errors.New("team ID cannot be empty")
var ErrBoardIDsAndPatchesMissmatchInBoardsAndBlocks = errors.New("board ids and patches need to match")
var ErrBlockIDsAndPatchesMissmatchInBoardsAndBlocks = errors.New("block ids and patches need to match")

type BlockDoesntBelongToAnyBoardErr struct {
	blockID string
}

func (e BlockDoesntBelongToAnyBoardErr) Error() string {
	return fmt.Sprintf("block %s doesn't belong to any board", e.blockID)
}

// BoardsAndBlocks is used to operate over boards and blocks at the
// same time
// swagger:model
type BoardsAndBlocks struct {
	// The boards
	// required: false

View on GitHub (pinned to a84bbb65e3)