{"record":{"id":"52de0939c1167e28","repo":"RocketChat/Rocket.Chat","slug":"error-invalid-param-52de09","errorCode":"error-invalid-param","errorMessage":"sidebarCategories contains a blank category name","messagePattern":"sidebarCategories contains a blank category name","errorType":"validation","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/meteor-methods/users/saveUserPreferences.ts","lineNumber":104,"sourceCode":"\t\treturn;\n\t}\n\n\tconst updateNotificationResponse = await Subscriptions.updateNotificationUserPreferences(userId, newValue, setting, preferenceType);\n\tif (updateNotificationResponse.modifiedCount) {\n\t\tvoid notifyOnSubscriptionChangedByUserPreferences(userId, preferenceType, 'subscription');\n\t}\n}\n\nconst MAX_CATEGORY_NAME_LENGTH = 30;\n\nexport const validateSidebarCategories = (categories: ISidebarCategory[]): void => {\n\tfor (const category of categories) {\n\t\tif (category.default) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst trimmed = category.name.trim();\n\t\tif (!trimmed) {\n\t\t\tthrow new Meteor.Error('error-invalid-param', 'sidebarCategories contains a blank category name');\n\t\t}\n\t\tif (trimmed.length > MAX_CATEGORY_NAME_LENGTH) {\n\t\t\tthrow new Meteor.Error('error-invalid-param', 'sidebarCategories category name exceeds maximum length');\n\t\t}\n\t}\n\n\tconst hasDuplicates = (values: string[]): boolean => new Set(values).size !== values.length;\n\tif (hasDuplicates(categories.map((category) => category._id))) {\n\t\tthrow new Meteor.Error('error-invalid-param', 'sidebarCategories contains duplicate category _id values');\n\t}\n};\n\nexport const saveUserPreferences = async (settings: Partial<UserPreferences>, userId: string): Promise<void> => {\n\tconst keys = {\n\t\tlanguage: Match.Optional(String),\n\t\tnewRoomNotification: Match.Optional(String),\n\t\tnewMessageNotification: Match.Optional(String),\n\t\tclockMode: Match.Optional(Number),","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b263243745917337314259cf987c0e989cf0cdc9/apps/meteor/server/meteor-methods/users/saveUserPreferences.ts#L86-L122","documentation":"saveUserPreferences throws error-invalid-param with message 'sidebarCategories contains a blank category name' when a sidebarCategories entry in user preferences has a name that is empty or only whitespace. validateSidebarCategories skips default categories (default: true) but requires custom categories to have a non-blank trimmed name. This protects the sidebar UI from unnameable categories.","triggerScenarios":"Calling the saveUserPreferences meteor method (e.g. via user preferences save from the account UI or API) with sidebarCategories containing { name: '' }, { name: '   ' }, or a category whose name is undefined/null stringified.","commonSituations":"Saving a new sidebar category from a form where the name input was left blank; trimming/normalization logic upstream deleting the name; importing or syncing preferences from another source with missing names.","solutions":["Require a non-empty category name in the form/UI before enabling save (disable the save button when the trimmed name is empty)","Default the name to a sensible fallback (e.g. 'Untitled') when creating a category client-side","If syncing preferences programmatically, filter out blank-named categories before calling saveUserPreferences","Trim input client-side so whitespace-only names are caught early with a friendly validation message"],"exampleFix":"// before\nsaveUserPreferences({ sidebarCategories: [{ _id: 'cat1', name: '   ' }] }, userId);\n\n// after\nsaveUserPreferences({ sidebarCategories: [{ _id: 'cat1', name: 'My Category' }] }, userId);","handlingStrategy":"validation","validationCode":"const ok = categories.every((c) => c.default === true || (typeof c.name === 'string' && c.name.trim().length > 0));\nif (!ok) throw new TypeError('every custom sidebar category needs a non-blank name');","typeGuard":"const hasValidCategoryNames = (cats: { name?: string; default?: boolean }[]): boolean => cats.every((c) => c.default || (typeof c.name === 'string' && c.name.trim().length > 0));","tryCatchPattern":null,"preventionTips":["Mark the name input as required and block save while empty","Trim names client-side before submission","Filter blank-named categories out of synced preference payloads"],"tags":["meteor","user-preferences","sidebar","validation"],"backgroundTag":"request-body-validation-failed","analyzedSha":"b263243745917337314259cf987c0e989cf0cdc9","analyzedAt":"2026-08-28T13:18:22.752Z","contentChangedAt":"2026-08-28T13:18:22.752Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}