{"record":{"id":"c849e45e82e6fb5f","repo":"RocketChat/Rocket.Chat","slug":"error-app-prevented","errorCode":"error-app-prevented","errorMessage":"error.message","messagePattern":"error\\.message","errorType":"error_code","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/lib/media/file-upload/lib/FileUpload.ts","lineNumber":206,"sourceCode":"\t\t}\n\n\t\t// E2EE files should be of type application/octet-stream. no information about them should be disclosed on upload if they are encrypted\n\t\tif (isE2EEUpload(file)) {\n\t\t\tfile.type = 'application/octet-stream';\n\t\t}\n\n\t\t// E2EE files are of type application/octet-stream, which is whitelisted for E2EE files\n\t\tif (!fileUploadIsValidContentType(file?.type, isE2EEUpload(file) ? 'application/octet-stream' : undefined)) {\n\t\t\tconst reason = i18n.t('File_type_is_not_accepted', { lng: language });\n\t\t\tthrow new Meteor.Error('error-invalid-file-type', reason);\n\t\t}\n\n\t\t// App IPreFileUpload event hook\n\t\ttry {\n\t\t\tawait Apps.self?.triggerEvent(AppEvents.IPreFileUpload, { file, content });\n\t\t} catch (error: any) {\n\t\t\tif (error.name === AppsEngineException.name) {\n\t\t\t\tthrow new Meteor.Error('error-app-prevented', error.message);\n\t\t\t}\n\n\t\t\tthrow error;\n\t\t}\n\n\t\treturn true;\n\t},\n\n\tasync validateAvatarUpload(file: IUpload) {\n\t\tif (!Match.test(file.rid, String) && !Match.test(file.userId, String)) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst user = file.uid ? await Users.findOne(file.uid, { projection: { language: 1 } }) : null;\n\t\tconst language = user?.language || 'en';\n\n\t\t// accept only images the browser can display as an avatar\n\t\tif (!isRenderableImageType(file.type)) {","sourceCodeStart":188,"sourceCodeEnd":224,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/lib/media/file-upload/lib/FileUpload.ts#L188-L224","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Identify which app blocked it: read the error.message payload and check Administration > Apps for apps registering IPreFileUpload","Adjust the file or the app's configuration so the upload satisfies the app's rule","Disable or remove the blocking app if the behavior is unintended","If you author the app, throw a descriptive AppsEngineException so users see an actionable reason"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await FileUpload.validateFileUpload(file, content);\n} catch (error: any) {\n  if (error instanceof Meteor.Error && error.error === 'error-app-prevented') {\n    // an installed App rejected the upload; error.message carries the app's reason\n    showAppRejection(error.message);\n    return;\n  }\n  throw error;\n}","preventionTips":["Maintain a list of apps registering IPreFileUpload on your workspace","Surface the app's reason message to users verbatim","Test uploads after installing/updating apps"],"tags":["apps-engine","file-upload","app-hook","ipre-file-upload","app-prevented"],"backgroundTag":"apps-engine-blocked-action","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}