RocketChat/Rocket.Chat · error · Meteor.Error
error-app-prevented
error-app-prevented
Error message
error.message
What it means
Meteor.Error('error-app-prevented') thrown when an app's IPreRoomUserJoined handler throws an AppsEngineException during addUserToRoom; the app's message becomes the reason. Non-app errors are rethrown as-is.
Source
Thrown at apps/meteor/server/lib/rooms/addUserToRoom.ts:75
try {
const inviterUser = inviter && ((await Users.findOneById(inviter._id)) || undefined);
// Not "duplicated": we're moving away from callbacks so this is a patch function. We should migrate the next one to be a patch or use this same patch, instead of calling both
await beforeAddUserToRoomPatch([userToBeAdded.username!], room, inviterUser);
await beforeAddUserToRoom.run({ user: userToBeAdded, inviter: inviterUser }, room);
} catch (error) {
throw new Meteor.Error((error as any)?.message);
}
// TODO: are we calling this twice?
await callbacks.run('beforeAddedToRoom', { user: userToBeAdded, inviter });
try {
await Apps.self?.triggerEvent(AppEvents.IPreRoomUserJoined, room, userToBeAdded, inviter);
} catch (error: any) {
if (error.name === AppsEngineException.name) {
throw new Meteor.Error('error-app-prevented', error.message);
}
throw error;
}
// for federation rooms we stop here since everything else will be handled by the federation invite flow
if (isRoomNativeFederated(room)) {
return;
}
// TODO: are we calling this twice?
if (room.t === 'c' || room.t === 'p' || room.t === 'l') {
// Add a new event, with an optional inviter
await callbacks.run('beforeAddedToRoom', { user: userToBeAdded, inviter }, room);
// Keep the current event
await callbacks.run('beforeJoinRoom', userToBeAdded, room);
}View on GitHub (pinned to b2c16d5842)
Solutions
- Read the app-provided message for the veto reason.
- Adjust the app's rules or configuration for the affected room/user.
- Disable or update the app if the veto is wrong.
Defensive patterns
Strategy: try-catch
Try / catch
try {
await addUserToRoom(rid, user, inviter);
} catch (error: any) {
if (error?.error === 'error-app-prevented') {
// error.reason is the app's veto message for IPreRoomUserJoined
}
} Prevention
- List apps implementing IPreRoomUserJoined when adds fail unexpectedly.
- Keep app join policies configurable per room or role.
- Surface the app's reason in moderation UIs.
When it happens
Trigger: An installed app vetoes adding a specific user to a room while addUserToRoom processes the membership add.
Common situations: Apps gating joins by approval, reputation, or external policy; app regressions blocking all adds.
Related errors
- error-app-prevented
- error-app-prevented-deleting
- error-app-prevented
- Only channels, private groups and direct messages can be cre
- Invalid user
AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18).
Data as JSON: /api/errors/87be16864067da90.
Report an issue: GitHub.