{"record":{"id":"4644e67a3989ac12","repo":"RocketChat/Rocket.Chat","slug":"error-app-prevented-4644e6","errorCode":"error-app-prevented","errorMessage":"error.message","messagePattern":"error\\.message","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/lib/rooms/acceptRoomInvite.ts","lineNumber":38,"sourceCode":"export const performAcceptRoomInvite = async (\n\troom: IRoom,\n\tsubscription: ISubscription,\n\tuser: IUser & { username: string },\n): Promise<void> => {\n\tif (subscription.status !== 'INVITED' || !subscription.inviter) {\n\t\tthrow new Meteor.Error('error-not-invited', `User was not invited to this room ${subscription.status}`);\n\t}\n\tconst inviter = await Users.findOneById(subscription.inviter._id);\n\n\tawait callbacks.run('beforeJoinRoom', user, room);\n\n\tawait callbacks.run('beforeAddedToRoom', { user, inviter }, room);\n\n\ttry {\n\t\tawait Apps.self?.triggerEvent(AppEvents.IPreRoomUserJoined, room, user, inviter);\n\t} catch (error: any) {\n\t\tif (error.name === AppsEngineException.name) {\n\t\t\tthrow new Meteor.Error('error-app-prevented', error.message);\n\t\t}\n\n\t\tthrow error;\n\t}\n\n\tawait Subscriptions.acceptInvitationById(subscription._id);\n\n\tvoid notifyOnSubscriptionChangedById(subscription._id, 'updated');\n\n\tawait Message.saveSystemMessage('uj', room._id, user.username, user);\n\n\tif (room.t === 'c' || room.t === 'p') {\n\t\tprocess.nextTick(async () => {\n\t\t\t// Add a new event, with an optional inviter\n\t\t\tawait callbacks.run('afterAddedToRoom', { user, inviter }, room);\n\n\t\t\t// Keep the current event\n\t\t\tawait callbacks.run('afterJoinRoom', user, room);","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/lib/rooms/acceptRoomInvite.ts#L20-L56","documentation":"Meteor.Error('error-app-prevented') thrown when an installed Rocket.Chat App's IPreRoomUserJoined event handler throws an AppsEngineException while a user accepts a room invite. The app's own message becomes the error reason; non-app errors are rethrown untouched.","triggerScenarios":"An app implementing IPreRoomUserJoined (join-policy, approval, compliance apps) vetoes the join during acceptRoomInvite.","commonSituations":"Apps enforcing approval workflows or external checks on joins; app misconfiguration blocking everyone; app updates with stricter defaults.","solutions":["Read the error message - it is the app's explanation for the veto.","Adjust the app's rules or configuration for this room/user.","Disable or update the app if the block is unintended."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await performAcceptRoomInvite(room, subscription, user);\n} catch (error: any) {\n  if (error?.error === 'error-app-prevented') {\n    // error.reason is the app's veto message: surface it to the user\n  }\n}","preventionTips":["Review installed apps hooking IPreRoomUserJoined when invites fail.","Keep app block rules aligned with workspace policy.","Surfacing the app's reason prevents 'cannot join' mystery reports."],"tags":["apps-engine","apps","rooms","event-veto"],"backgroundTag":"app-event-prevented","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","contentChangedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}