{"record":{"id":"9244bb33554dd7de","repo":"flowable/flowable-engine","slug":"unsupported-variable-scope-type","errorCode":null,"errorMessage":"unsupported variable scope type: ","messagePattern":"unsupported variable scope type: ","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/scripting/VariableScopeResolver.java","lineNumber":65,"sourceCode":"            \"identityService\", ProcessEngineConfiguration::getIdentityService,\n            // the identity service was historically exposed under this name, kept for backwards compatibility\n            \"identityServiceKey\", ProcessEngineConfiguration::getIdentityService\n    );\n\n    public VariableScopeResolver(ProcessEngineConfigurationImpl processEngineConfiguration, VariableContainer scopeContainer,\n            VariableContainer inputVariableContainer) {\n\n        this.processEngineConfiguration = processEngineConfiguration;\n\n        if (scopeContainer == null) {\n            throw new FlowableIllegalArgumentException(\"scopeContainer cannot be null\");\n        }\n        if (scopeContainer instanceof ExecutionEntity) {\n            variableScopeKey = \"execution\";\n        } else if (scopeContainer instanceof TaskEntity) {\n            variableScopeKey = \"task\";\n        } else {\n            throw new FlowableException(\"unsupported variable scope type: \" + scopeContainer.getClass().getName());\n        }\n        this.scopeContainer = scopeContainer;\n        this.inputVariableContainer = inputVariableContainer;\n    }\n\n    @Override\n    public boolean containsKey(Object key) {\n        return variableScopeKey.equals(key) || inputVariableContainer.hasVariable((String) key)\n                || SERVICE_RESOLVERS.containsKey(key) && processEngineConfiguration.isServicesEnabledInScripting();\n    }\n\n    @Override\n    public Object get(Object key) {\n        if (variableScopeKey.equals(key)) {\n            return scopeContainer;\n        } else if (SERVICE_RESOLVERS.containsKey((String) key)) {\n            if (processEngineConfiguration.isServicesEnabledInScripting()) {\n                return SERVICE_RESOLVERS.get(key).apply(processEngineConfiguration);","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/scripting/VariableScopeResolver.java#L47-L83","documentation":"FlowableException thrown by the VariableScopeResolver constructor when scopeContainer is neither an ExecutionEntity nor a TaskEntity. The resolver only knows how to map these two variable scope types to a variableScopeKey ('execution' or 'task').","triggerScenarios":"Constructing VariableScopeResolver with a custom VariableContainer implementation, a CaseInstance/other scope type, or a mock/stub of VariableContainer in tests that is not ExecutionEntity/TaskEntity.","commonSituations":"Unit tests passing Mockito mocks of VariableContainer; custom scripting integrations passing CaseTask or standalone variable containers; Flowable version changes where new scope types are not supported by this resolver.","solutions":["Pass the actual DelegateExecution (ExecutionEntity) or DelegateTask (TaskEntity) instead of a generic VariableContainer.","In tests, mock ExecutionEntity/TaskEntity types rather than the VariableContainer interface.","If a new scope type is genuinely needed, register/extend the resolver rather than feeding unsupported containers into this constructor."],"exampleFix":"// before\nnew VariableScopeResolver(config, myCustomVariableContainer, inputVariables);\n\n// after\nnew VariableScopeResolver(config, (VariableContainer) executionEntity, inputVariables);","handlingStrategy":"type-guard","validationCode":"if (!(scope instanceof ExecutionEntity) && !(scope instanceof TaskEntity)) {\n    throw new IllegalArgumentException(\"scope must be ExecutionEntity or TaskEntity, got \"\n        + (scope == null ? \"null\" : scope.getClass().getName()));\n}","typeGuard":"boolean isSupportedScope(VariableContainer c) {\n    return c instanceof ExecutionEntity || c instanceof TaskEntity;\n}","tryCatchPattern":"try {\n    resolver = new VariableScopeResolver(config, scope, inputVars);\n} catch (FlowableException e) {\n    log.error(\"unsupported scope type: {}\", e.getMessage());\n    throw e;\n}","preventionTips":["Pass engine-native DelegateExecution/DelegateTask, not custom wrappers","In unit tests mock the concrete entity types, not VariableContainer","Check supported scope types before extending custom scripting integration"],"tags":["flowable","scripting","unsupported-type"],"backgroundTag":"invalid-argument-value","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}