flowable/flowable-engine · error · ActivitiIllegalArgumentException

Task id is null

Error message

Task id is null

What it means

This is thrown by TaskQueryImpl.taskId() when the caller passes a null task id to the query builder. The Flowable/Activiti engine rejects null filter values up front instead of issuing a broken or unbounded SQL query. It is a fail-fast argument validation inside the fluent TaskQuery API.

Solutions

  1. Ensure a non-null task id before calling taskId(), e.g. check the variable or lookup result first
  2. Wrap the query build in a try-catch for ActivitiIllegalArgumentException to surface a friendly message
  3. If the id is genuinely unknown, skip the query or use a different filter (e.g. processInstanceId) instead

Example fix

// before
Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
// after
if (taskId != null) {
    Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
}
Defensive patterns

Strategy: validation

Validate before calling

if (taskId == null) { throw new IllegalArgumentException("taskId must be provided before querying"); }

Type guard

boolean hasTaskId(String id) { return id != null && !id.trim().isEmpty(); }

Try / catch

try { return taskService.createTaskQuery().taskId(taskId).singleResult(); } catch (ActivitiIllegalArgumentException e) { log.warn("Invalid task query: {}", e.getMessage()); return null; }

Prevention

When it happens

Trigger: Calling taskService.createTaskQuery().taskId(null), typically when the task id variable is uninitialized or the result of a failed lookup was not checked before building the query.

Common situations: Chaining taskId(someMap.get("taskId")) where the map key is absent; using a process variable that was never set; a refactor changed the source of the id and it now returns null.

Related errors


AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11). Data as JSON: /api/errors/95b7fe85a4948b9a. Report an issue: GitHub.

Appendix: source

Thrown at modules/flowable5-engine/src/main/java/org/activiti/engine/impl/TaskQueryImpl.java:134

    }

    public TaskQueryImpl(CommandContext commandContext) {
        super(commandContext);
    }

    public TaskQueryImpl(CommandExecutor commandExecutor) {
        super(commandExecutor);
    }

    public TaskQueryImpl(CommandExecutor commandExecutor, String databaseType) {
        super(commandExecutor);
        this.databaseType = databaseType;
    }

    @Override
    public TaskQueryImpl taskId(String taskId) {
        if (taskId == null) {
            throw new ActivitiIllegalArgumentException("Task id is null");
        }

        if (orActive) {
            currentOrQueryObject.taskId = taskId;
        } else {
            this.taskId = taskId;
        }
        return this;
    }

    @Override
    public TaskQueryImpl taskName(String name) {
        if (name == null) {
            throw new ActivitiIllegalArgumentException("Task name is null");
        }

        if (orActive) {
            currentOrQueryObject.name = name;

View on GitHub (pinned to d6d39ce1c6)