RocketChat/Rocket.Chat · error · Meteor.Error
error-invalid-param
error-invalid-param
Error message
sidebarCategories contains a blank category name
What it means
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.
Source
Thrown at apps/meteor/server/meteor-methods/users/saveUserPreferences.ts:104
return;
}
const updateNotificationResponse = await Subscriptions.updateNotificationUserPreferences(userId, newValue, setting, preferenceType);
if (updateNotificationResponse.modifiedCount) {
void notifyOnSubscriptionChangedByUserPreferences(userId, preferenceType, 'subscription');
}
}
const MAX_CATEGORY_NAME_LENGTH = 30;
export const validateSidebarCategories = (categories: ISidebarCategory[]): void => {
for (const category of categories) {
if (category.default) {
continue;
}
const trimmed = category.name.trim();
if (!trimmed) {
throw new Meteor.Error('error-invalid-param', 'sidebarCategories contains a blank category name');
}
if (trimmed.length > MAX_CATEGORY_NAME_LENGTH) {
throw new Meteor.Error('error-invalid-param', 'sidebarCategories category name exceeds maximum length');
}
}
const hasDuplicates = (values: string[]): boolean => new Set(values).size !== values.length;
if (hasDuplicates(categories.map((category) => category._id))) {
throw new Meteor.Error('error-invalid-param', 'sidebarCategories contains duplicate category _id values');
}
};
export const saveUserPreferences = async (settings: Partial<UserPreferences>, userId: string): Promise<void> => {
const keys = {
language: Match.Optional(String),
newRoomNotification: Match.Optional(String),
newMessageNotification: Match.Optional(String),
clockMode: Match.Optional(Number),View on GitHub (pinned to b263243745)
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
Example fix
// before
saveUserPreferences({ sidebarCategories: [{ _id: 'cat1', name: ' ' }] }, userId);
// after
saveUserPreferences({ sidebarCategories: [{ _id: 'cat1', name: 'My Category' }] }, userId); Defensive patterns
Strategy: validation
Validate before calling
const ok = categories.every((c) => c.default === true || (typeof c.name === 'string' && c.name.trim().length > 0));
if (!ok) throw new TypeError('every custom sidebar category needs a non-blank name'); Type guard
const hasValidCategoryNames = (cats: { name?: string; default?: boolean }[]): boolean => cats.every((c) => c.default || (typeof c.name === 'string' && c.name.trim().length > 0)); Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- duplicated-account
- error-invalid-account
- error-user-registration-custom-field
- error-invalid-room-name
- error-message-same-as-tmid
AI-assisted analysis of RocketChat/Rocket.Chat@b263243745 (2026-08-28).
Data as JSON: /api/errors/52de0939c1167e28.
Report an issue: GitHub.