{"record":{"id":"d1c9e1823362fa3b","repo":"RocketChat/Rocket.Chat","slug":"invalid-user-status-type","errorCode":null,"errorMessage":"Invalid user status type","messagePattern":"Invalid user status type","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/client/lib/userStatuses.ts","lineNumber":40,"sourceCode":"\t\t\t\tid: status,\n\t\t\t\tname: status,\n\t\t\t\tstatusType: status,\n\t\t\t\tlocalizeName: true,\n\t\t\t},\n\t\t]),\n\t);\n\n\tpublic delete(id: string): void {\n\t\tthis.store.delete(id);\n\t}\n\n\tpublic put(customUserStatus: UserStatusDescriptor): void {\n\t\tthis.store.set(customUserStatus.id, customUserStatus);\n\t}\n\n\tpublic createFromCustom(customUserStatus: Omit<ICustomUserStatus, '_updatedAt'>): UserStatusDescriptor {\n\t\tif (!this.isValidType(customUserStatus.statusType)) {\n\t\t\tthrow new Error('Invalid user status type');\n\t\t}\n\n\t\treturn {\n\t\t\tname: customUserStatus.name,\n\t\t\tid: customUserStatus._id,\n\t\t\tstatusType: customUserStatus.statusType as UserStatus,\n\t\t\tlocalizeName: false,\n\t\t};\n\t}\n\n\tpublic isValidType(type: string): type is UserStatus {\n\t\treturn (Object.values(UserStatus) as string[]).includes(type);\n\t}\n\n\tpublic *[Symbol.iterator]() {\n\t\tfor (const value of this.store.values()) {\n\t\t\tif (this.invisibleAllowed || value.statusType !== UserStatus.OFFLINE) {\n\t\t\t\tyield value;","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/f9d3ec372bb580fa8d036f94cf03925a478ef768/apps/meteor/client/lib/userStatuses.ts#L22-L58","documentation":"Thrown by createFromCustom on the UserStatuses store when the provided customUserStatus.statusType is not a valid value in the UserStatus enum. isValidType checks whether the string is among Object.values(UserStatus). The UserStatus enum contains values like 'online', 'away', 'busy', 'offline' (and possibly others). This validates that a custom status name maps to a recognised status type.","triggerScenarios":"A custom user status is created with a statusType string that is not in the UserStatus enum (e.g., 'invisible', 'do-not-disturb', or a typo like 'busyy'). Data from an external source or API response includes a status type the client does not recognise. Version mismatch: the server sends a status type added in a newer version the client doesn't know.","commonSituations":"Server-side custom status plugin adds new status types the client enum doesn't include. Imported data from a third-party integration with different status type names. Client-server version skew after a server upgrade. Hardcoded status type string with a typo in custom integration code.","solutions":["Validate the statusType against Object.values(UserStatus) before calling createFromCustom.","Ensure client and server are on compatible versions that share the same UserStatus enum values.","Map external status types to known UserStatus values before creating a custom status.","Catch the error and fall back to a default status type (e.g., 'online')."],"exampleFix":"// before\nconst status = userStatuses.createFromCustom({ _id, name, statusType: inputType });\n// after\nif (!userStatuses.isValidType(inputType)) {\n  inputType = UserStatus.ONLINE; // fallback\n}\nconst status = userStatuses.createFromCustom({ _id, name, statusType: inputType });","handlingStrategy":"type-guard","validationCode":"if (!userStatuses.isValidType(statusType)) {\n  statusType = UserStatus.ONLINE; // fallback to default\n}\nconst status = userStatuses.createFromCustom({ _id, name, statusType });","typeGuard":"userStatuses.isValidType(type: string): type is UserStatus  // already provided by the library\n// usage:\nif (userStatuses.isValidType(inputType)) {\n  // inputType is narrowed to UserStatus\n  userStatuses.createFromCustom({ ..., statusType: inputType });\n}","tryCatchPattern":"try {\n  const status = userStatuses.createFromCustom({ _id, name, statusType });\n} catch (e) {\n  if (e instanceof Error && e.message === 'Invalid user status type') {\n    // fall back to a valid type\n    statusType = UserStatus.ONLINE;\n  }\n}","preventionTips":["Always call isValidType before createFromCustom.","Map external status types to known UserStatus enum values.","Keep client and server versions aligned to avoid enum mismatch.","Default unknown status types to a safe value like UserStatus.ONLINE."],"tags":["user-status","validation","enum","type-check","version-mismatch"],"backgroundTag":null,"analyzedSha":"f9d3ec372bb580fa8d036f94cf03925a478ef768","analyzedAt":"2026-08-12T19:07:17.372Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}