flowable/flowable-engine · error · FlowableException
unsupported variable scope type:
Error message
unsupported variable scope type:
What it means
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').
Source
Thrown at modules/flowable-engine/src/main/java/org/flowable/engine/impl/scripting/VariableScopeResolver.java:65
"identityService", ProcessEngineConfiguration::getIdentityService,
// the identity service was historically exposed under this name, kept for backwards compatibility
"identityServiceKey", ProcessEngineConfiguration::getIdentityService
);
public VariableScopeResolver(ProcessEngineConfigurationImpl processEngineConfiguration, VariableContainer scopeContainer,
VariableContainer inputVariableContainer) {
this.processEngineConfiguration = processEngineConfiguration;
if (scopeContainer == null) {
throw new FlowableIllegalArgumentException("scopeContainer cannot be null");
}
if (scopeContainer instanceof ExecutionEntity) {
variableScopeKey = "execution";
} else if (scopeContainer instanceof TaskEntity) {
variableScopeKey = "task";
} else {
throw new FlowableException("unsupported variable scope type: " + scopeContainer.getClass().getName());
}
this.scopeContainer = scopeContainer;
this.inputVariableContainer = inputVariableContainer;
}
@Override
public boolean containsKey(Object key) {
return variableScopeKey.equals(key) || inputVariableContainer.hasVariable((String) key)
|| SERVICE_RESOLVERS.containsKey(key) && processEngineConfiguration.isServicesEnabledInScripting();
}
@Override
public Object get(Object key) {
if (variableScopeKey.equals(key)) {
return scopeContainer;
} else if (SERVICE_RESOLVERS.containsKey((String) key)) {
if (processEngineConfiguration.isServicesEnabledInScripting()) {
return SERVICE_RESOLVERS.get(key).apply(processEngineConfiguration);View on GitHub (pinned to d6d39ce1c6)
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.
Example fix
// before new VariableScopeResolver(config, myCustomVariableContainer, inputVariables); // after new VariableScopeResolver(config, (VariableContainer) executionEntity, inputVariables);
Defensive patterns
Strategy: type-guard
Validate before calling
if (!(scope instanceof ExecutionEntity) && !(scope instanceof TaskEntity)) {
throw new IllegalArgumentException("scope must be ExecutionEntity or TaskEntity, got "
+ (scope == null ? "null" : scope.getClass().getName()));
} Type guard
boolean isSupportedScope(VariableContainer c) {
return c instanceof ExecutionEntity || c instanceof TaskEntity;
} Try / catch
try {
resolver = new VariableScopeResolver(config, scope, inputVars);
} catch (FlowableException e) {
log.error("unsupported scope type: {}", e.getMessage());
throw e;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- 'language' evaluated to null for taskListener of type 'scrip
- Script content is null or evaluated to null for taskListener
- scopeContainer cannot be null
- The service '${key}' is not available in the current context
- Unsupported variableContainer for key '${CASE_INSTANCE_KEY}'
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/9244bb33554dd7de.
Report an issue: GitHub.