flowable/flowable-engine · error · org.flowable.common.engine.api.FlowableIllegalArgumentException
taskId is empty
Error message
taskId is empty
What it means
InternalVariableInstanceQueryImpl.taskId(String) throws FlowableIllegalArgumentException when the given taskId is null or an empty string. The variable-instance query API requires a non-empty task id to filter variables by task; passing blank input would produce a broken or full-table query, so the builder rejects it eagerly. This fail-fast validation happens at query-construction time, before any database access.
Solutions
- Ensure a non-empty task id is resolved before building the query
- Check the upstream source of the task id for empty/blank values
- If the goal is 'variables not tied to a task', call withoutTaskId() instead of passing an empty id
Example fix
// before
query.taskId(task.getId()); // NPE/empty when task not yet persisted
// after
if (task != null && task.getId() != null) {
query.taskId(task.getId());
} else {
query.withoutTaskId();
} Defensive patterns
Strategy: validation
Validate before calling
if (taskId == null || taskId.isEmpty()) { throw new IllegalArgumentException("taskId must be non-empty before querying"); } Type guard
boolean hasTaskId(String id) { return id != null && !id.isEmpty(); } Try / catch
try { query.taskId(taskId); } catch (FlowableIllegalArgumentException e) { log.warn("Invalid taskId for variable query", e); return Collections.emptyList(); } Prevention
- Validate ids at the service boundary before building queries
- Never pass ids derived from unvalidated request input directly into Flowable queries
- Remember StringUtils.isEmpty does not trim; trim/blank-check manually if whitespace matters
When it happens
Trigger: Calling internalVariableInstanceQuery taskId(null) or taskId("") — e.g. a task id variable that was never initialized, or a value derived from an empty JSON/HTTP field.
Common situations: Task id fetched from an upstream API or form field that is blank; refactor left the id unset; whitespace-only strings (StringUtils.isEmpty treats only null and "" as empty, so " " passes and may return no results).
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- executionId is empty
- None of the given process categories can be null
- processInstanceId is empty
- scopeId is empty
- Task id list is null
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/b5fbe0449d9958aa.
Report an issue: GitHub.
Appendix: source
Thrown at modules/flowable-variable-service/src/main/java/org/flowable/variable/service/impl/InternalVariableInstanceQueryImpl.java:68
protected boolean withoutSubScopeId;
protected String scopeType;
protected Collection<String> scopeTypes;
protected String name;
protected Collection<String> names;
@Override
public InternalVariableInstanceQuery id(String id) {
if (StringUtils.isEmpty(id)) {
throw new FlowableIllegalArgumentException("id is empty");
}
this.id = id;
return this;
}
@Override
public InternalVariableInstanceQuery taskId(String taskId) {
if (StringUtils.isEmpty(taskId)) {
throw new FlowableIllegalArgumentException("taskId is empty");
}
if (withoutTaskId) {
throw new FlowableIllegalArgumentException("Cannot combine taskId(String) with withoutTaskId() in the same query");
}
this.taskId = taskId;
return this;
}
@Override
public InternalVariableInstanceQuery taskIds(Collection<String> taskIds) {
if (taskIds == null || taskIds.isEmpty()) {
throw new FlowableIllegalArgumentException("taskIds is null or empty");
}
if (withoutTaskId) {
throw new FlowableIllegalArgumentException("Cannot combine taskIds(Collection) with withoutTaskId() in the same query");View on GitHub (pinned to d6d39ce1c6)