RocketChat/Rocket.Chat · error · Meteor.Error

error-app-prevented

error-app-prevented

Error message

error.message

What it means

Before accepting an upload, validateFileUpload fires the Apps Engine IPreFileUpload event (FileUpload.ts:201-210). If an installed Rocket.Chat App rejects the file from that hook by throwing an AppsEngineException, the server wraps it as a Meteor.Error 'error-app-prevented' carrying the app's own message. This is an intentional block by app business logic, not an infrastructure failure; any other error from the hook is rethrown unchanged.

Source

Thrown at apps/meteor/server/lib/media/file-upload/lib/FileUpload.ts:206

		}

		// E2EE files should be of type application/octet-stream. no information about them should be disclosed on upload if they are encrypted
		if (isE2EEUpload(file)) {
			file.type = 'application/octet-stream';
		}

		// E2EE files are of type application/octet-stream, which is whitelisted for E2EE files
		if (!fileUploadIsValidContentType(file?.type, isE2EEUpload(file) ? 'application/octet-stream' : undefined)) {
			const reason = i18n.t('File_type_is_not_accepted', { lng: language });
			throw new Meteor.Error('error-invalid-file-type', reason);
		}

		// App IPreFileUpload event hook
		try {
			await Apps.self?.triggerEvent(AppEvents.IPreFileUpload, { file, content });
		} catch (error: any) {
			if (error.name === AppsEngineException.name) {
				throw new Meteor.Error('error-app-prevented', error.message);
			}

			throw error;
		}

		return true;
	},

	async validateAvatarUpload(file: IUpload) {
		if (!Match.test(file.rid, String) && !Match.test(file.userId, String)) {
			return false;
		}

		const user = file.uid ? await Users.findOne(file.uid, { projection: { language: 1 } }) : null;
		const language = user?.language || 'en';

		// accept only images the browser can display as an avatar
		if (!isRenderableImageType(file.type)) {

View on GitHub (pinned to b2c16d5842)

Solutions

  1. Identify which app blocked it: read the error.message payload and check Administration > Apps for apps registering IPreFileUpload
  2. Adjust the file or the app's configuration so the upload satisfies the app's rule
  3. Disable or remove the blocking app if the behavior is unintended
  4. If you author the app, throw a descriptive AppsEngineException so users see an actionable reason
Defensive patterns

Strategy: try-catch

Try / catch

try {
  await FileUpload.validateFileUpload(file, content);
} catch (error: any) {
  if (error instanceof Meteor.Error && error.error === 'error-app-prevented') {
    // an installed App rejected the upload; error.message carries the app's reason
    showAppRejection(error.message);
    return;
  }
  throw error;
}

Prevention

When it happens

Trigger: Any installed app implementing IPreFileUpload (antivirus, DLP, moderation, file-filter apps) rejecting the upload based on its own rules: blocked extension, suspicious content, policy violation; a locally developed app throwing AppsEngineException during testing.

Common situations: Enterprise installs with antivirus/DLP apps silently tightening rules after an app update; admins unaware an app intercepts uploads; app authors raising generic exceptions with unhelpful messages; CI/integration tests hitting a server with such an app enabled.

Related errors


AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18). Data as JSON: /api/errors/c849e45e82e6fb5f. Report an issue: GitHub.