flowable/flowable-engine · error · FlowableIllegalArgumentException
Cannot set global variable
Error message
Cannot set global variable '${name}' on task '${task.getId()}', task is not part of process. What it means
A standalone task (not linked to a process execution, executionId == null) cannot hold global variables, since global scope means the execution/process scope. Flowable throws FlowableIllegalArgumentException when a global-scope variable is set on such a task.
Solutions
- Use "variableScope": "local" (or omit scope; defaults to local) for standalone tasks
- Attach the task to a process instance if global variables are genuinely needed
- Handle the error in clients that accept both process and standalone tasks
Example fix
// before
{"name": "priority", "value": 3, "variableScope": "global"} // standalone task
// after
{"name": "priority", "value": 3, "variableScope": "local"} Defensive patterns
Strategy: type-guard
Validate before calling
const task = await api.get(`/runtime/tasks/${taskId}`); if (!task.data.executionId && scope === 'global') { throw new Error('Standalone task: only local variables allowed'); } Type guard
function canSetGlobal(task) { return Boolean(task && task.executionId); } Try / catch
try { await setVariable(taskId, var); } catch (e) { if (isIllegalArgument(e) && /not part of process/.test(e.message)) { await setVariable(taskId, {...var, variableScope: 'local'}); } else { throw e; } } Prevention
- Only send variableScope=global for tasks with an executionId
- Default to local scope when uncertain
- Branch on standalone vs process tasks in client code
When it happens
Trigger: POST/PUT /runtime/tasks/{taskId}/variables with "variableScope": "global" on a task created outside any process instance (e.g. via the standalone task REST/TaskService API).
Common situations: Standalone tasks created via POST /runtime/tasks; code paths reused between process tasks and standalone tasks; assuming every task belongs to a process; task's process instance already ended so execution link is gone.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Cannot set global variables on task
- Can only unacquire BPMN or CMMN external job. Job with id
- Cannot set global variables on task
- Only allowed to update multiple variables in the same scope.
- Only allowed to update multiple variables in the same scope.
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/9648cedc6ecac5bb.
Report an issue: GitHub.
Appendix: source
Thrown at modules/flowable-rest/src/main/java/org/flowable/rest/service/api/runtime/task/TaskVariableBaseResource.java:249
if (restApiInterceptor != null) {
if (isNew) {
restApiInterceptor.createTaskVariables(task, Collections.singletonMap(name, value), scope);
} else {
restApiInterceptor.updateTaskVariables(task, Collections.singletonMap(name, value), scope);
}
}
if (scope == RestVariableScope.LOCAL) {
taskService.setVariableLocal(task.getId(), name, value);
} else {
if (task.getExecutionId() != null) {
// Explicitly set on execution, setting non-local variable on
// task will override local-variable if exists
runtimeService.setVariable(task.getExecutionId(), name, value);
} else {
// Standalone task, no global variables possible
throw new FlowableIllegalArgumentException("Cannot set global variable '" + name + "' on task '" + task.getId() + "', task is not part of process.");
}
}
}
}
View on GitHub (pinned to d6d39ce1c6)