{"record":{"id":"522dbb5d0186bacc","repo":"mattermost-community/focalboard","slug":"not-a-card-block","errorCode":null,"errorMessage":"not a card block","messagePattern":"not a card block","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/model/card.go","lineNumber":27,"sourceCode":")\n\nvar ErrBoardIDMismatch = errors.New(\"Board IDs do not match\")\n\ntype ErrInvalidCard struct {\n\tmsg string\n}\n\nfunc NewErrInvalidCard(msg string) ErrInvalidCard {\n\treturn ErrInvalidCard{\n\t\tmsg: msg,\n\t}\n}\n\nfunc (e ErrInvalidCard) Error() string {\n\treturn fmt.Sprintf(\"invalid card, %s\", e.msg)\n}\n\nvar ErrNotCardBlock = errors.New(\"not a card block\")\n\ntype ErrInvalidFieldType struct {\n\tfield string\n}\n\nfunc (e ErrInvalidFieldType) Error() string {\n\treturn fmt.Sprintf(\"invalid type for field '%s'\", e.field)\n}\n\n// Card represents a group of content blocks and properties.\n// swagger:model\ntype Card struct {\n\t// The id for this card\n\t// required: false\n\tID string `json:\"id\"`\n\n\t// The id for board this card belongs to.\n\t// required: false","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/mattermost-community/focalboard/blob/a84bbb65e32edf972856b329417096ac413518e9/server/model/card.go#L9-L45","documentation":"ErrNotCardBlock is a sentinel error in the Mattermost Boards model package indicating that a block was expected to be a card-type block but was not. Block2Card converts a generic Block into a Card and throws this when the block's Type is not TypeCard. It guards against silently misinterpreting non-card blocks (e.g. boards, text blocks) as cards.","triggerScenarios":"Calling Block2Card with a Block whose Type field is not 'card' — e.g. passing a board block, text block, or image block loaded from the database or an import archive.","commonSituations":"Importing/archiving boards where blocks were mixed; queries that fetch blocks by parent ID without filtering type; refactors that assume a returned slice contains only cards.","solutions":["Verify the Block.Type equals model.TypeCard before calling Block2Card","Filter the block list to only card-type blocks before conversion","Check whether the API that produced the block was queried with the correct block type"],"exampleFix":"// before\ncard := model.Block2Card(block)\n// after\nif block.Type != model.TypeCard {\n    return nil, fmt.Errorf(\"block %s is %s, not a card\", block.ID, block.Type)\n}\ncard := model.Block2Card(block)","handlingStrategy":"validation","validationCode":"if block.Type != model.TypeCard {\n    // handle or skip: not convertible to a card\n    return fmt.Errorf(\"block %s is not a card\", block.ID)\n}","typeGuard":"func isCardBlock(b model.Block) bool {\n    return b.Type == model.TypeCard\n}","tryCatchPattern":"card, err := model.Block2Card(block)\nif err != nil {\n    if errors.Is(err, model.ErrNotCardBlock) {\n        continue // skip non-card block\n    }\n    return err\n}","preventionTips":["Filter queries to card type blocks before conversion","Assert block type in table-driven tests around Block2Card","Never assume slices of blocks are homogeneous"],"tags":["go","type-mismatch","blocks"],"backgroundTag":"unexpected-block-type","analyzedSha":"a84bbb65e32edf972856b329417096ac413518e9","analyzedAt":"2026-08-30T09:22:20.720Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}