{"record":{"id":"83c4d6beef3340f2","repo":"mattermost-community/focalboard","slug":"w-userid-s","errorCode":null,"errorMessage":"%w userID: %s","messagePattern":"%w userID: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/app/boards.go","lineNumber":293,"sourceCode":"\treturn newBoard, nil\n}\n\nfunc (a *App) addBoardsToDefaultCategory(userID, teamID string, boards []*model.Board) error {\n\tuserCategoryBoards, err := a.GetUserCategoryBoards(userID, teamID)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tdefaultCategoryID := \"\"\n\tfor _, categoryBoard := range userCategoryBoards {\n\t\tif categoryBoard.Name == defaultCategoryBoards {\n\t\t\tdefaultCategoryID = categoryBoard.ID\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif defaultCategoryID == \"\" {\n\t\treturn fmt.Errorf(\"%w userID: %s\", errNoDefaultCategoryFound, userID)\n\t}\n\n\tboardIDs := make([]string, len(boards))\n\tfor i := range boards {\n\t\tboardIDs[i] = boards[i].ID\n\t}\n\n\tif err := a.AddUpdateUserCategoryBoard(teamID, userID, defaultCategoryID, boardIDs); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}\n\nfunc (a *App) PatchBoard(patch *model.BoardPatch, boardID, userID string) (*model.Board, error) {\n\tvar oldChannelID string\n\tvar isTemplate bool\n\tvar oldMembers []*model.BoardMember","sourceCodeStart":275,"sourceCodeEnd":311,"githubUrl":"https://github.com/mattermost-community/focalboard/blob/a84bbb65e32edf972856b329417096ac413518e9/server/app/boards.go#L275-L311","documentation":"addBoardsToDefaultCategory assigns boards to the user's default 'Board' category in a team. If no default category can be found (no category named/type Board for that user+team), it wraps the package sentinel errNoDefaultCategoryFound with the userID. It is reached from CreateBoard, setBoardCategoryFromSource, AddMemberToBoard and CreateBoardsAndBlocks.","triggerScenarios":"Creating a board or adding a member in a team where the user has no default board category: the team's categories were never initialized for that user, the default category was renamed/deleted, or category initialization failed at first login.","commonSituations":"Fresh teams where Onboarding/initializeCategories hasn't run; users whose categories were removed by a bug or manual DB edit; duplicated-board flows into a new team (toTeam) lacking the user's categories.","solutions":["Initialize the user's default categories for the team (call the category-initialization path, e.g. a.getOrCreateCategory / onboarding flow) before adding boards.","Check errors.Is(err, errNoDefaultCategoryFound) to confirm the cause and handle it by creating the default 'Board' category.","Verify the categories table has a row of type 'board' for (userID, teamID); create it if missing.","When duplicating into another team, ensure category initialization runs for the target team first."],"exampleFix":"// caller-side\nerr := a.CreateBoard(board, userID)\nif err != nil && errors.Is(err, errNoDefaultCategoryFound) {\n    if cErr := a.initializeDefaultCategories(userID, board.TeamID); cErr != nil {\n        return cErr\n    }\n    return a.CreateBoard(board, userID) // retry after init\n}","handlingStrategy":"validation","validationCode":"categories, err := app.GetCategoriesForTeam(teamID, userID)\nif err != nil {\n    return err\n}\nhasDefault := false\nfor _, c := range categories {\n    if c.Type == model.CategoryTypeBoard {\n        hasDefault = true\n        break\n    }\n}\nif !hasDefault {\n    if _, err := app.CreateCategory(&model.Category{Name: \"Boards\", TeamID: teamID, UserID: userID, Type: model.CategoryTypeBoard}, userID); err != nil {\n        return err\n    }\n}","typeGuard":"func hasDefaultBoardCategory(cats []*model.Category) bool {\n    for _, c := range cats {\n        if c.Type == model.CategoryTypeBoard {\n            return true\n        }\n    }\n    return false\n}","tryCatchPattern":"if err := a.CreateBoard(board, userID); err != nil {\n    if errors.Is(err, errNoDefaultCategoryFound) {\n        if cErr := a.initializeDefaultCategories(userID, board.TeamID); cErr != nil {\n            return cErr\n        }\n        return a.CreateBoard(board, userID)\n    }\n    return err\n}","preventionTips":["Always run category initialization for (userID, teamID) on first board creation or membership.","Never delete or retype the default 'Board' category via direct DB edits.","When duplicating boards into another team, initialize that team's categories first.","Match on errors.Is(err, errNoDefaultCategoryFound), not on string text."],"tags":["categories","board","not-found","wrapped-error"],"backgroundTag":"default-category-not-found","analyzedSha":"a84bbb65e32edf972856b329417096ac413518e9","analyzedAt":"2026-08-30T09:22:20.720Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}