Activiti/Activiti · error · ActivitiIllegalArgumentException

taskId and taskIds are null

Error message

taskId and taskIds are null

What it means

DeleteTaskCmd accepts either a single taskId or a collection taskIds; if both are null there is nothing to delete, so it throws ActivitiIllegalArgumentException. This guards against calling the command with no target at all.

Solutions

  1. Ensure either taskId or taskIds is populated before invoking the delete call.
  2. If the id list may be legitimately empty, guard with a size check and skip the call.
  3. Centralize the delete helper to validate inputs once.

Example fix

// before
taskService.deleteTask(taskId); // taskId and taskIds both null
// after
if (taskId == null && (taskIds == null || taskIds.isEmpty())) {
    return; // nothing to delete
}
taskService.deleteTask(taskId);
Defensive patterns

Strategy: validation

Validate before calling

if ((taskId == null || taskId.isEmpty()) && (taskIds == null || taskIds.isEmpty())) {
    throw new IllegalArgumentException("Provide taskId or taskIds");
}

Try / catch

try {
    taskService.deleteTask(taskId);
} catch (ActivitiIllegalArgumentException e) {
    log.error("No task id(s) provided", e);
}

Prevention

When it happens

Trigger: TaskService.deleteTask(null) with taskIds also null, or constructing new DeleteTaskCmd(null, null, ...) — usually when the caller intended to pass one of the two but both variables were empty.

Common situations: Batch-delete helpers where the list ended up empty/null after filtering, refactored APIs where a collection parameter was dropped, or copying a call and forgetting to replace the id placeholder with a real value.

Related errors


AI-assisted analysis of Activiti/Activiti@56435b1a97 (2026-09-09). Data as JSON: /api/errors/7af8f8b72457510a. Report an issue: GitHub.

Appendix: source

Thrown at activiti-core/activiti-engine/src/main/java/org/activiti/engine/impl/cmd/DeleteTaskCmd.java:66

        this(taskIds, deleteReason, cascade, false);
    }

    public DeleteTaskCmd(Collection<String> taskIds, String deleteReason, boolean cascade, boolean cancel) {
        this.taskIds = taskIds;
        this.cascade = cascade;
        this.deleteReason = deleteReason;
        this.cancel = cancel;
    }

    public Void execute(CommandContext commandContext) {
        if (taskId != null) {
            deleteTask(commandContext, taskId);
        } else if (taskIds != null) {
            for (String taskId : taskIds) {
                deleteTask(commandContext, taskId);
            }
        } else {
            throw new ActivitiIllegalArgumentException("taskId and taskIds are null");
        }

        return null;
    }

    protected void deleteTask(CommandContext commandContext, String taskId) {
        commandContext.getTaskEntityManager().deleteTask(taskId, deleteReason, cascade, cancel);
    }
}

View on GitHub (pinned to 56435b1a97)