{"record":{"id":"7ef20d353c3687f4","repo":"Activiti/Activiti","slug":"unsupported-variable-scope-type-classname","errorCode":null,"errorMessage":"unsupported variable scope type: ${className}","messagePattern":"unsupported variable scope type: (.+?)","errorType":"exception","errorClass":"ActivitiException","httpStatus":null,"severity":"error","filePath":"activiti-core/activiti-engine/src/main/java/org/activiti/engine/impl/scripting/VariableScopeResolver.java","lineNumber":67,"sourceCode":"        historyServiceKey,\n        formServiceKey\n    );\n\n    public VariableScopeResolver(\n        ProcessEngineConfigurationImpl processEngineConfiguration,\n        VariableScope variableScope\n    ) {\n        this.processEngineConfiguration = processEngineConfiguration;\n\n        if (variableScope == null) {\n            throw new ActivitiIllegalArgumentException(\"variableScope cannot be null\");\n        }\n        if (variableScope instanceof ExecutionEntity) {\n            variableScopeKey = \"execution\";\n        } else if (variableScope instanceof TaskEntity) {\n            variableScopeKey = \"task\";\n        } else {\n            throw new ActivitiException(\"unsupported variable scope type: \" + variableScope.getClass().getName());\n        }\n        this.variableScope = variableScope;\n    }\n\n    public boolean containsKey(Object key) {\n        return variableScopeKey.equals(key) || KEYS.contains(key) || variableScope.hasVariable((String) key);\n    }\n\n    public Object get(Object key) {\n        if (variableScopeKey.equals(key)) {\n            return variableScope;\n        } else if (processEngineConfigurationKey.equals(key)) {\n            return processEngineConfiguration;\n        } else if (runtimeServiceKey.equals(key)) {\n            return processEngineConfiguration.getRuntimeService();\n        } else if (taskServiceKey.equals(key)) {\n            return processEngineConfiguration.getTaskService();\n        } else if (repositoryServiceKey.equals(key)) {","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/Activiti/Activiti/blob/56435b1a97deeafdc09dd40074b056c89fba5a8a/activiti-core/activiti-engine/src/main/java/org/activiti/engine/impl/scripting/VariableScopeResolver.java#L49-L85","documentation":"VariableScopeResolver only knows how to expose ExecutionEntity (bound as 'execution') and TaskEntity (bound as 'task') scopes; any other VariableScope implementation triggers this ActivitiException naming the class. This enforces that scripts can only resolve variables from supported scope objects. Custom VariableScope implementations must be handled by extending the resolver or converting to a supported scope first.","triggerScenarios":"Creating VariableScopeResolver with a VariableScope instance that is neither ExecutionEntity nor TaskEntity — e.g. a custom VariableScope implementation, a CaseExecution-like scope, or a test fake implementing VariableScope.","commonSituations":"Unit tests passing mock/fake VariableScope objects into scripting engines; custom scope classes added by embedders; using Activiti APIs with foreign scope wrappers; version upgrades where the resolver's supported types were narrowed.","solutions":["Pass the actual ExecutionEntity or TaskEntity associated with the script evaluation instead of a custom wrapper.","Extend or subclass the resolver (or provide a custom ScriptBindingManager) to support your VariableScope type.","In tests, use a real ExecutionEntity/TaskEntity (e.g. from the engine's test fixtures) rather than a mock VariableScope.","Unwrap your custom scope to the underlying execution before creating script bindings."],"exampleFix":"// before\nresolver = new VariableScopeResolver(config, myCustomScope);\n\n// after\nresolver = new VariableScopeResolver(config, (ExecutionEntity) myCustomScope.getExecution());","handlingStrategy":"validation","validationCode":"if (!(variableScope instanceof ExecutionEntity) && !(variableScope instanceof TaskEntity)) {\n    throw new IllegalArgumentException(\n        \"Unsupported scope for script bindings: \" + variableScope.getClass().getName());\n}","typeGuard":"boolean isSupportedScope(VariableScope scope) {\n    return scope instanceof ExecutionEntity || scope instanceof TaskEntity;\n}","tryCatchPattern":"try {\n    new VariableScopeResolver(config, variableScope);\n} catch (ActivitiException e) {\n    if (e.getMessage().startsWith(\"unsupported variable scope type\")) {\n        logger.error(\"Convert {} to ExecutionEntity/TaskEntity before creating bindings\",\n            variableScope.getClass().getName(), e);\n    }\n}","preventionTips":["Only pass engine-managed ExecutionEntity or TaskEntity objects into scripting APIs.","Avoid mock VariableScope fakes in tests; use engine test fixtures with real entities.","If you need custom scopes, plan for a custom resolver/binding extension instead of forcing them through VariableScopeResolver."],"tags":["scripting","unsupported-type","activiti","bindings"],"backgroundTag":"unsupported-operation","analyzedSha":"56435b1a97deeafdc09dd40074b056c89fba5a8a","analyzedAt":"2026-09-09T21:00:06.703Z","contentChangedAt":"2026-09-09T21:00:06.703Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}