{"record":{"id":"0bf5d82cb18ff83e","repo":"flowable/flowable-engine","slug":"taskid-is-null-0bf5d8","errorCode":null,"errorMessage":"taskId is null","messagePattern":"taskId is null","errorType":"exception","errorClass":"ActivitiIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cmd/NeedsActiveTaskCmd.java","lineNumber":44,"sourceCode":" * An abstract superclass for {@link Command} implementations that want to verify the provided task is always active (ie. not suspended).\n * \n * @author Joram Barrez\n */\npublic abstract class NeedsActiveTaskCmd<T> implements Command<T>, Serializable {\n\n    private static final long serialVersionUID = 1L;\n\n    protected String taskId;\n\n    public NeedsActiveTaskCmd(String taskId) {\n        this.taskId = taskId;\n    }\n\n    @Override\n    public T execute(CommandContext commandContext) {\n\n        if (taskId == null) {\n            throw new ActivitiIllegalArgumentException(\"taskId is null\");\n        }\n\n        TaskEntity task = commandContext\n                .getTaskEntityManager()\n                .findTaskById(taskId);\n\n        if (task == null) {\n            throw new ActivitiObjectNotFoundException(\"Cannot find task with id \" + taskId, Task.class);\n        }\n\n        if (task.isSuspended()) {\n            throw new ActivitiException(getSuspendedTaskException());\n        }\n\n        return execute(commandContext, task);\n    }\n\n    /**","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cmd/NeedsActiveTaskCmd.java#L26-L62","documentation":"NeedsActiveTaskCmd.execute() validates that a taskId was supplied before looking up the task, throwing ActivitiIllegalArgumentException when it is null. This is a programmer error: the command object was constructed without its required task identifier.","triggerScenarios":"Constructing a task command (complete, claim, resolve, set assignee, add comment, etc.) with a null taskId, typically from an unbound request parameter or an uninitialized variable, then executing it via the command executor or a task service call.","commonSituations":"Web controllers binding an optional 'taskId' path/form parameter that is absent; refactoring that removed the id-population step; unit tests invoking commands directly with an incomplete constructor.","solutions":["Ensure the calling task service method receives a non-null taskId; trace where the id is loaded (request param, task object) and fix the null source.","Add an explicit null check or @NotNull validation at the API/controller boundary before invoking the engine.","In tests, pass a real taskId obtained from taskService.createTaskQuery() instead of a placeholder null."],"exampleFix":"// before\nString taskId = request.getParameter(\"taskId\");\ntaskService.complete(taskId);\n\n// after\nString taskId = request.getParameter(\"taskId\");\nif (taskId == null || taskId.isEmpty()) {\n    throw new BadRequestException(\"taskId is required\");\n}\ntaskService.complete(taskId);","handlingStrategy":"validation","validationCode":"if (taskId == null || taskId.trim().isEmpty()) throw new IllegalArgumentException(\"taskId is required\");","typeGuard":"boolean hasTaskId(String taskId) { return taskId != null && !taskId.trim().isEmpty(); }","tryCatchPattern":"try {\n    taskService.complete(taskId);\n} catch (ActivitiIllegalArgumentException e) {\n    log.error(\"Missing taskId\");\n}","preventionTips":["Validate request parameters at the controller layer","Use @NotNull/@NotBlank bean validation on ids","Never construct engine commands with unset ids in tests or scripts"],"tags":["activiti","flowable","null-argument","task"],"backgroundTag":"null-argument","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-18T11:17:12.947Z"}