mattermost-community/focalboard · error

Board IDs do not match

Error message

Board IDs do not match

What it means

ErrBoardIDMismatch is a sentinel error in the Card model indicating that the card's board ID does not match the board ID of the request/path context. It is treated as a bad request (IsErrBadRequest) and surfaced by handlers such as handleCreateCard.

Source

Thrown at server/model/card.go:11

package model

import (
	"errors"
	"fmt"

	"github.com/mattermost/focalboard/server/utils"
	"github.com/rivo/uniseg"
)

var ErrBoardIDMismatch = errors.New("Board IDs do not match")

type ErrInvalidCard struct {
	msg string
}

func NewErrInvalidCard(msg string) ErrInvalidCard {
	return ErrInvalidCard{
		msg: msg,
	}
}

func (e ErrInvalidCard) Error() string {
	return fmt.Sprintf("invalid card, %s", e.msg)
}

var ErrNotCardBlock = errors.New("not a card block")

type ErrInvalidFieldType struct {

View on GitHub (pinned to a84bbb65e3)

Solutions

  1. Set the card's boardId to match the board ID in the request URL/path
  2. If moving a card to another board, use the proper move/update flow with a consistent boardId in both payload and route
  3. Check client state (e.g. selected board in the store) that supplied the mismatched ID

Example fix

// before
await client.createCard(boardIdFromUrl, {...card, boardId: oldBoardId})
// after
await client.createCard(boardIdFromUrl, {...card, boardId: boardIdFromUrl})
Defensive patterns

Strategy: validation

Validate before calling

if (card.boardId !== boardIdFromUrl) {
  throw new Error('card.boardId must match the board in the request URL')
}

Type guard

function hasMatchingBoardID(card, boardId) {
  return card && card.boardId === boardId
}

Try / catch

try {
  await client.createCard(boardId, card)
} catch (err) {
  if (err.response?.status === 400 && /Board IDs do not match/.test(err.message)) {
    console.error('Payload boardId does not match URL boardId')
  } else throw err
}

Prevention

When it happens

Trigger: POST /api/v2/cards (handleCreateCard) where the card payload's boardId differs from the boardId in the request URL; any card IsValid-style check comparing card.BoardID with an expected board ID.

Common situations: Client code copying a card between boards without updating card.BoardID; stale UI state holding an old board ID; API consumers hardcoding board IDs in payloads.

Related errors


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