{"record":{"id":"110903b12ddca828","repo":"RocketChat/Rocket.Chat","slug":"integration-scripts-unknown-engine","errorCode":null,"errorMessage":"integration-scripts-unknown-engine","messagePattern":"integration-scripts-unknown-engine","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/lib/integrations/lib/validateScriptEngine.ts","lineNumber":13,"sourceCode":"import type { IntegrationScriptEngine } from '@rocket.chat/core-typings';\nimport { wrapExceptions } from '@rocket.chat/tools';\n\nconst FREEZE_INTEGRATION_SCRIPTS_VALUE = String(process.env.FREEZE_INTEGRATION_SCRIPTS).toLowerCase();\nconst FREEZE_INTEGRATION_SCRIPTS = ['yes', 'true'].includes(FREEZE_INTEGRATION_SCRIPTS_VALUE);\n\nexport const validateScriptEngine = (engine?: IntegrationScriptEngine) => {\n\tif (FREEZE_INTEGRATION_SCRIPTS) {\n\t\tthrow new Error('integration-scripts-disabled');\n\t}\n\n\tif (engine && engine !== 'isolated-vm') {\n\t\tthrow new Error('integration-scripts-unknown-engine');\n\t}\n\n\tconst engineCode = 'ivm';\n\n\tif (engineCode === FREEZE_INTEGRATION_SCRIPTS_VALUE) {\n\t\tthrow new Error('integration-scripts-isolated-vm-disabled');\n\t}\n\n\treturn true;\n};\n\nexport const isScriptEngineFrozen = (engine?: IntegrationScriptEngine) =>\n\twrapExceptions(() => !validateScriptEngine(engine)).catch(() => true);\n","sourceCodeStart":1,"sourceCodeEnd":27,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/lib/integrations/lib/validateScriptEngine.ts#L1-L27","documentation":"validateScriptEngine throws this plain Error when a script engine name is supplied and it is not 'isolated-vm'. After the vm2 sandbox was removed, isolated-vm is the only supported engine for integration scripts, so legacy values like 'vm', 'vm2', 'eval', or 'nodejs' are rejected. The check runs whenever an integration's scriptEngine is validated, e.g. on save or before executing a script.","triggerScenarios":"Saving or executing an integration whose record still carries scriptEngine 'vm'/'vm2' (typical for records created on Rocket.Chat versions before the engine migration); calling integrations.create/update with an explicit scriptEngine other than 'isolated-vm'.","commonSituations":"Workspaces upgraded across major versions with old integration records; API clients porting payloads from old documentation that showed other engine names; hand-edited database records.","solutions":["Update the integration so scriptEngine is 'isolated-vm' (or omit it — validateOutgoingIntegration defaults it to 'isolated-vm')","Re-save the integration through Admin -> Integrations so the default is applied to the stored record","Test the script under the isolated-vm sandbox before flipping the field; older vm2 scripts may need adjustments"],"exampleFix":"// before — legacy record\nawait Integrations.updateAsync({ _id }, { $set: { scriptEngine: 'vm2' } });\n\n// after\nawait Integrations.updateAsync({ _id }, { $set: { scriptEngine: 'isolated-vm' } });","handlingStrategy":"type-guard","validationCode":"if (engine !== undefined && engine !== 'isolated-vm') {\n  throw new RangeError(`unsupported script engine '${engine}'; only 'isolated-vm' is allowed`);\n}","typeGuard":"const isSupportedScriptEngine = (e?: string): e is 'isolated-vm' | undefined =>\n  e === undefined || e === 'isolated-vm';","tryCatchPattern":"try {\n  validateScriptEngine(integration.scriptEngine);\n} catch (err) {\n  if (err instanceof Error && err.message === 'integration-scripts-unknown-engine') {\n    // legacy record: reset scriptEngine to 'isolated-vm' (or omit) and re-save\n  } else {\n    throw err;\n  }\n}","preventionTips":["Never send an explicit scriptEngine other than 'isolated-vm' (or omit the field)","After major upgrades, re-save legacy integrations so the default engine is persisted"],"tags":["integrations","script-engine","isolated-vm","migration"],"backgroundTag":"unsupported-script-engine","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","contentChangedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}