mattermost-community/focalboard · error

insertBoard error occurred while fetching existing board %s:

Error message

insertBoard error occurred while fetching existing board %s: %w

What it means

insertBoard first checks whether a board with the same ID already exists (to decide upsert vs insert) by calling getBoard; if that lookup fails with an error OTHER than not-found, this wrapped error is returned. It signals a genuine storage problem while reading existing board state, not a duplicate-ID situation.

Source

Thrown at server/services/store/sqlstore/board.go:329

			mlog.Err(err),
		)
		return nil, err
	}

	cardPropertiesBytes, err := s.MarshalJSONB(board.CardProperties)
	if err != nil {
		s.logger.Error(
			"failed to marshal board.CardProperties",
			mlog.String("board_id", board.ID),
			mlog.String("board.CardProperties", fmt.Sprintf("%v", board.CardProperties)),
			mlog.Err(err),
		)
		return nil, err
	}

	existingBoard, err := s.getBoard(db, board.ID)
	if err != nil && !model.IsErrNotFound(err) {
		return nil, fmt.Errorf("insertBoard error occurred while fetching existing board %s: %w", board.ID, err)
	}

	insertQuery := s.getQueryBuilder(db).Insert("").
		Columns(boardFields("")...)

	now := utils.GetMillis()
	board.ModifiedBy = userID
	board.UpdateAt = now

	insertQueryValues := map[string]interface{}{
		"id":               board.ID,
		"team_id":          board.TeamID,
		"channel_id":       board.ChannelID,
		"created_by":       board.CreatedBy,
		"modified_by":      board.ModifiedBy,
		"type":             board.Type,
		"title":            board.Title,
		"minimum_role":     board.MinimumRole,

View on GitHub (pinned to a84bbb65e3)

Solutions

  1. Inspect the wrapped err (%w) for the underlying DB error (connection refused, unknown table, etc.)
  2. Verify database connectivity and that the boards table exists (run migrations)
  3. Retry the operation if the failure was transient (connection blip)
  4. Check the DSN/credentials in your configuration match a healthy database

Example fix

// no code fix in caller; verify infra
// before
// server fails: insertBoard error occurred while fetching existing board ...
// after: ensure DB reachable and migrated
migrate_db.sh && restart server
Defensive patterns

Strategy: retry

Try / catch

board, err := store.InsertBoard(board, userID)
if err != nil && strings.Contains(err.Error(), "error occurred while fetching existing board") {
    // transient DB read failure — retry after checking connectivity
    time.Sleep(250 * time.Millisecond)
    board, err = store.InsertBoard(board, userID)
}

Prevention

When it happens

Trigger: InsertBoard (or patchBoard/insertBoardWithAdmin/createBoardsAndBlocks paths) when getBoard returns a connection error, table-missing error, permission failure, or any non-ErrNotFound database error.

Common situations: DB connection drops mid-request; migrations incomplete so the boards table doesn't exist; misconfigured DSN pointing at a wrong/locked database; transient read replicas issues.

Related errors


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