{"record":{"id":"a0620284444e45a0","repo":"RocketChat/Rocket.Chat","slug":"error-room-is-abac-managed","errorCode":"error-room-is-abac-managed","errorMessage":"error-room-is-abac-managed","messagePattern":"error-room-is-abac-managed","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"apps/meteor/ee/server/hooks/abac/beforeAddUserToRoom.ts","lineNumber":18,"sourceCode":"import { Abac } from '@rocket.chat/core-services';\nimport { License } from '@rocket.chat/license';\n\nimport { beforeAddUserToRoom } from '../../../../server/hooks/rooms/beforeAddUserToRoom';\nimport { settings } from '../../../../server/settings';\n\nbeforeAddUserToRoom.patch(async (prev, users, room, actor) => {\n\tawait prev(users, room, actor);\n\n\tconst validUsers = users.filter(Boolean);\n\t// No need to check ABAC when theres no users or when room is not private or when room is not ABAC managed\n\tif (!validUsers.length || room.t !== 'p' || !room?.abacAttributes?.length) {\n\t\treturn;\n\t}\n\n\t// Throw error (prevent add) if ABAC is disabled (setting, license) but room is ABAC managed\n\tif (!settings.get('ABAC_Enabled') || !License.hasModule('abac')) {\n\t\tthrow new Error('error-room-is-abac-managed');\n\t}\n\n\tawait Abac.checkUsernamesMatchAttributes(validUsers as string[], room.abacAttributes, room);\n});\n","sourceCodeStart":1,"sourceCodeEnd":23,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/ee/server/hooks/abac/beforeAddUserToRoom.ts#L1-L23","documentation":"Thrown by the ABAC beforeAddUserToRoom hook when someone adds users to a private room (t === 'p') that has abacAttributes configured, but the workspace cannot enforce ABAC: either the ABAC_Enabled setting is false or the license lacks the 'abac' module. The hook deliberately blocks the addition (fail-closed) so an access-controlled room never silently accepts members without attribute checks. Note it throws a plain Error with this code-like message after the original hook chain ran.","triggerScenarios":"addUserToRoom (direct call, REST, or UI invite) targeting a private room with non-empty abacAttributes while settings.get('ABAC_Enabled') is false OR !License.hasModule('abac'). Even a workspace admin adding themselves triggers it; the users list is only skipped when empty, the room is not private, or the room has no abacAttributes.","commonSituations":"ABAC was enabled once, rooms got abacAttributes, then the feature was disabled or the enterprise license (with ABAC) expired/downgraded; trial license lapsing after rooms were configured; admin toggling ABAC_Enabled off for testing while ABAC rooms exist.","solutions":["Re-enable ABAC: turn on the ABAC_Enabled setting and ensure an active license that includes the abac module, then retry the add (users will then be attribute-checked).","If ABAC is intentionally off, remove abacAttributes from the affected private rooms first so the guard no longer applies.","License problem: restore/renew the enterprise license including ABAC, or contact sales for the correct entitlement.","Do not attempt to bypass by direct DB member inserts — the room's access policy exists for a reason; clean up the room config instead."],"exampleFix":"// before\nawait Meteor.callAsync('addUserToRoom', { rid, username });\n// throws error-room-is-abac-managed on ABAC-configured private room\n\n// after: ensure enforcement is on before inviting\nif (room.t === 'p' && room.abacAttributes?.length) {\n  await ensureSetting('ABAC_Enabled', true);\n  await ensureLicenseModule('abac');\n}\nawait Meteor.callAsync('addUserToRoom', { rid, username });","handlingStrategy":"validation","validationCode":"// Client/server guard before adding users\nimport { settings } from '@rocket.chat/settings';\nimport { License } from '@rocket.chat/license';\nfunction canAddToRoom(room: { t: string; abacAttributes?: string[] }): boolean {\n  if (room.t !== 'p' || !room.abacAttributes?.length) return true;\n  return settings.get('ABAC_Enabled') && License.hasModule('abac');\n}","typeGuard":"function isAbacManagedPrivateRoom(room: { t: string; abacAttributes?: unknown }): room is { t: 'p'; abacAttributes: string[] } {\n  return room.t === 'p' && Array.isArray(room.abacAttributes) && room.abacAttributes.length > 0;\n}","tryCatchPattern":"try {\n  await addUserToRoom(users, room, actor);\n} catch (e) {\n  if (e instanceof Error && e.message === 'error-room-is-abac-managed') {\n    // fail-closed by design: fix the setting/license or strip room.abacAttributes; never bypass\n  }\n}","preventionTips":["Before disabling ABAC or downgrading licenses, strip abacAttributes from all private rooms.","Audit for ABAC-managed rooms whenever license entitlements change.","Treat this error as a security stop, not a bug: resolve the policy mismatch instead of catching around it."],"tags":["abac","access-control","rooms","license","enterprise","fail-closed"],"backgroundTag":"license-feature-disabled","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"}