{"record":{"id":"546a750ccf3ec624","repo":"RocketChat/Rocket.Chat","slug":"error-max-rooms-per-guest-reached","errorCode":"error-max-rooms-per-guest-reached","errorMessage":"error-max-rooms-per-guest-reached","messagePattern":"error-max-rooms-per-guest-reached","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/ee/server/startup/maxRoomsPerGuest.ts","lineNumber":14,"sourceCode":"import { License } from '@rocket.chat/license';\nimport { Meteor } from 'meteor/meteor';\n\nimport { callbacks } from '../../../server/lib/callbacks';\nimport { i18n } from '../../../server/lib/i18n';\n\ncallbacks.add(\n\t'beforeAddedToRoom',\n\tasync ({ user }) => {\n\t\tif (user.roles?.includes('guest')) {\n\t\t\t// extraCount = 1 checks if adding one more room would exceed the limit\n\t\t\t// (not if they've already exceeded it, since this runs before adding them to the room)\n\t\t\tif (await License.shouldPreventAction('roomsPerGuest', 1, { userId: user._id })) {\n\t\t\t\tthrow new Meteor.Error('error-max-rooms-per-guest-reached', i18n.t('error-max-rooms-per-guest-reached'));\n\t\t\t}\n\t\t}\n\t},\n\tcallbacks.priority.MEDIUM,\n\t'check-max-rooms-per-guest',\n);\n","sourceCodeStart":1,"sourceCodeEnd":21,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/ee/server/startup/maxRoomsPerGuest.ts#L1-L21","documentation":"Enterprise licensing guard registered on the 'beforeAddedToRoom' callback: when the user being added to a room has the 'guest' role and License.shouldPreventAction('roomsPerGuest', 1, { userId }) returns true — i.e. adding one more room would exceed the license's rooms-per-guest limit — the add is blocked with this Meteor.Error whose message comes from the i18n key of the same name.","triggerScenarios":"Any flow that adds a guest user to a room (addUserToRoom, room creation with members, team/channel invites) while that guest is already at the licensed roomsPerGuest cap.","commonSituations":"Guest users hitting the room cap of an Enterprise license; integrations auto-adding guests to many rooms; license downgrade lowering the cap below current usage.","solutions":["Remove the guest from a room they no longer need, then retry the add.","Raise the roomsPerGuest limit in the license (work with sales/licensing) if the business requires more.","Verify the user should actually have the 'guest' role — removing the role opts the user out of this check.","Check the license status and limits in the admin license area to confirm the cap in force."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if (user.roles?.includes('guest')) {\n\tif (await License.shouldPreventAction('roomsPerGuest', 1, { userId: user._id })) {\n\t\t// skip the add and inform the user instead of letting the callback throw\n\t}\n}","typeGuard":"const isGuest = (user: { roles?: string[] }): boolean => !!user.roles?.includes('guest');","tryCatchPattern":"try {\n\tawait addUserToRoom(rid, username);\n} catch (e) {\n\tif (e instanceof Meteor.Error && e.error === 'error-max-rooms-per-guest-reached') {\n\t\t// surface 'remove the guest from another room first' to the caller\n\t}\n\tthrow e;\n}","preventionTips":["Track guest room counts against the licensed roomsPerGuest cap in admin dashboards","Review guest memberships before renewals/downgrades that change license limits","Confirm the 'guest' role is only assigned to users who must be capped"],"tags":["licensing","enterprise","guests","rooms","limits"],"backgroundTag":"license-limit-exceeded","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","contentChangedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}