{"record":{"id":"d067a3114cbe2f97","repo":"flowable/flowable-engine","slug":"unsupported-variable-scope-type-variablescope-g","errorCode":null,"errorMessage":"unsupported variable scope type: ${variableScope.getClass().getName()}","messagePattern":"unsupported variable scope type: (.+?)","errorType":"exception","errorClass":"org.activiti.engine.ActivitiException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/scripting/VariableScopeResolver.java","lineNumber":42,"sourceCode":" * \n * @author Tom Baeyens\n * @author Joram Barrez\n */\npublic class VariableScopeResolver implements Resolver {\n\n    protected VariableScope variableScope;\n    protected String variableScopeKey = \"execution\";\n\n    public VariableScopeResolver(VariableScope variableScope) {\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    @Override\n    public boolean containsKey(Object key) {\n        return variableScopeKey.equals(key) || variableScope.hasVariable((String) key);\n    }\n\n    @Override\n    public Object get(Object key) {\n        if (variableScopeKey.equals(key)) {\n            return variableScope;\n        }\n\n        return variableScope.getVariable((String) key);\n    }\n}","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/scripting/VariableScopeResolver.java#L24-L60","documentation":"VariableScopeResolver only supports ExecutionEntity ('execution') and TaskEntity ('task') as variable scopes, mapping them to the script variable key it exposes. Any other VariableScope implementation is rejected with this ActivitiException naming the concrete class.","triggerScenarios":"Passing a custom VariableScope implementation (or a wrapper scope from an extension or a different engine module) into new VariableScopeResolver(...) for script evaluation.","commonSituations":"Custom scope wrappers introduced by extensions; mixing flowable6 scope classes into the flowable5 scripting path; mock VariableScope test doubles used in unit tests.","solutions":["Pass the underlying ExecutionEntity or TaskEntity instead of a wrapper/custom implementation.","Extend VariableScopeResolver to support the custom scope type (add an instanceof branch with its own variableScopeKey).","Check imports: use org.activiti.engine.impl.persistence.entity.ExecutionEntity/TaskEntity, not a different module's types."],"exampleFix":"// before\nnew VariableScopeResolver(customScopeWrapper);\n// after\nVariableScope real = ((CustomScopeWrapper) scope).getInnerScope(); // must be ExecutionEntity or TaskEntity\nnew VariableScopeResolver(real);","handlingStrategy":"type-guard","validationCode":"if (!(scope instanceof ExecutionEntity) && !(scope instanceof TaskEntity)) {\n    throw new IllegalArgumentException(\"Unsupported scope type: \" + scope.getClass().getName());\n}","typeGuard":"boolean isSupportedScope(VariableScope s) {\n    return s instanceof org.activiti.engine.impl.persistence.entity.ExecutionEntity\n        || s instanceof org.activiti.engine.impl.persistence.entity.TaskEntity;\n}","tryCatchPattern":"try {\n    resolver = new VariableScopeResolver(scope);\n} catch (ActivitiException e) {\n    if (e.getMessage().startsWith(\"unsupported variable scope type\")) { /* unwrap the inner scope */ }\n}","preventionTips":["Pass the raw ExecutionEntity/TaskEntity, never wrapper or custom VariableScope implementations","Check imports for scope classes — don't mix flowable5/flowable6 types","If a custom scope is required, extend VariableScopeResolver with a new instanceof branch"],"tags":["scripting","type-mismatch","unsupported-type"],"backgroundTag":"type-mismatch","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-18T11:17:12.947Z"}