{"record":{"id":"7af8f8b72457510a","repo":"Activiti/Activiti","slug":"taskid-and-taskids-are-null","errorCode":null,"errorMessage":"taskId and taskIds are null","messagePattern":"taskId and taskIds are null","errorType":"validation","errorClass":"ActivitiIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"activiti-core/activiti-engine/src/main/java/org/activiti/engine/impl/cmd/DeleteTaskCmd.java","lineNumber":66,"sourceCode":"        this(taskIds, deleteReason, cascade, false);\n    }\n\n    public DeleteTaskCmd(Collection<String> taskIds, String deleteReason, boolean cascade, boolean cancel) {\n        this.taskIds = taskIds;\n        this.cascade = cascade;\n        this.deleteReason = deleteReason;\n        this.cancel = cancel;\n    }\n\n    public Void execute(CommandContext commandContext) {\n        if (taskId != null) {\n            deleteTask(commandContext, taskId);\n        } else if (taskIds != null) {\n            for (String taskId : taskIds) {\n                deleteTask(commandContext, taskId);\n            }\n        } else {\n            throw new ActivitiIllegalArgumentException(\"taskId and taskIds are null\");\n        }\n\n        return null;\n    }\n\n    protected void deleteTask(CommandContext commandContext, String taskId) {\n        commandContext.getTaskEntityManager().deleteTask(taskId, deleteReason, cascade, cancel);\n    }\n}\n","sourceCodeStart":48,"sourceCodeEnd":76,"githubUrl":"https://github.com/Activiti/Activiti/blob/56435b1a97deeafdc09dd40074b056c89fba5a8a/activiti-core/activiti-engine/src/main/java/org/activiti/engine/impl/cmd/DeleteTaskCmd.java#L48-L76","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Ensure either taskId or taskIds is populated before invoking the delete call.","If the id list may be legitimately empty, guard with a size check and skip the call.","Centralize the delete helper to validate inputs once."],"exampleFix":"// before\ntaskService.deleteTask(taskId); // taskId and taskIds both null\n// after\nif (taskId == null && (taskIds == null || taskIds.isEmpty())) {\n    return; // nothing to delete\n}\ntaskService.deleteTask(taskId);","handlingStrategy":"validation","validationCode":"if ((taskId == null || taskId.isEmpty()) && (taskIds == null || taskIds.isEmpty())) {\n    throw new IllegalArgumentException(\"Provide taskId or taskIds\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    taskService.deleteTask(taskId);\n} catch (ActivitiIllegalArgumentException e) {\n    log.error(\"No task id(s) provided\", e);\n}","preventionTips":["Check list emptiness before batch delete helpers","Validate at least one target exists before invoking delete"],"tags":["null-argument","task","validation"],"backgroundTag":"null-argument","analyzedSha":"56435b1a97deeafdc09dd40074b056c89fba5a8a","analyzedAt":"2026-09-09T21:00:06.703Z","contentChangedAt":"2026-09-09T21:00:06.703Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}