mattermost-community/focalboard · error
cannot create card: %w
Error message
cannot create card: %w
What it means
CreateCard converts the Card model into a Block and inserts it via InsertBlocksAndNotify. This error wraps any failure of that insertion (validation, store write, or notification pipeline) under the message 'cannot create card'. The card is not created when this is returned.
Source
Thrown at server/app/cards.go:29
)
func (a *App) CreateCard(card *model.Card, boardID string, userID string, disableNotify bool) (*model.Card, error) {
// Convert the card struct to a block and insert the block.
now := utils.GetMillis()
card.ID = utils.NewID(utils.IDTypeCard)
card.BoardID = boardID
card.CreatedBy = userID
card.ModifiedBy = userID
card.CreateAt = now
card.UpdateAt = now
card.DeleteAt = 0
block := model.Card2Block(card)
newBlocks, err := a.InsertBlocksAndNotify([]*model.Block{block}, userID, disableNotify)
if err != nil {
return nil, fmt.Errorf("cannot create card: %w", err)
}
newCard, err := model.Block2Card(newBlocks[0])
if err != nil {
return nil, err
}
return newCard, nil
}
func (a *App) GetCardsForBoard(boardID string, page int, perPage int) ([]*model.Card, error) {
opts := model.QueryBlocksOptions{
BoardID: boardID,
BlockType: model.TypeCard,
Page: page,
PerPage: perPage,
}
View on GitHub (pinned to a84bbb65e3)
Solutions
- Inspect the wrapped cause from errors.Unwrap — fix the underlying validation or store error it names.
- Validate the card (Title, BoardID/ParentID set, valid types) before calling CreateCard.
- Confirm the target board exists and the user has permission to add blocks to it.
- Check plugin/websocket notification hooks for panics or rejections if validation and store are fine.
Defensive patterns
Strategy: validation
Validate before calling
func validateCard(c *model.Card) error {
if c == nil {
return errors.New("card is nil")
}
if strings.TrimSpace(c.Title) == "" {
return errors.New("card title is required")
}
if c.BoardID == "" {
return errors.New("card BoardID is required")
}
return nil
}
// call validateCard(card) before app.CreateCard Type guard
func isValidCard(c *model.Card) bool {
return c != nil && strings.TrimSpace(c.Title) != "" && c.BoardID != ""
} Try / catch
card, err := app.CreateCard(card, userID, false)
if err != nil {
if strings.Contains(err.Error(), "cannot create card") {
return fmt.Errorf("card creation rejected: %w", errors.Unwrap(err))
}
return err
} Prevention
- Validate card fields (title, boardID) client- and server-side before insert.
- Confirm the target board exists and permits block inserts.
- Unwrap the error to find whether validation, store, or a notification hook failed.
- Keep plugin WatchBlockChange hooks defensive (no panics, no hard rejections).
When it happens
Trigger: App.CreateCard failing inside InsertBlocksAndNotify: invalid card fields (empty title/boardID, bad parentID), block validation failure, store insert error, or an error thrown by the block-change notification hook (websocket/plugin subscribers).
Common situations: API clients posting cards missing required fields; database outages; a plugin's WatchBlockChange hook rejecting the insert; board ID pointing to a deleted board.
Related errors
- Block2Card fail: %w
- no user ID
- No User IDs
- block fields size limit exceeded
- at least one board is required
AI-assisted analysis of mattermost-community/focalboard@a84bbb65e3 (2026-08-30).
Data as JSON: /api/errors/767456050d539471.
Report an issue: GitHub.