{"record":{"id":"0e0ad44389f9d2fe","repo":"flowable/flowable-engine","slug":"taskid-is-null-0e0ad4","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/GetTaskVariablesCmd.java","lineNumber":47,"sourceCode":" * @author Joram Barrez\n */\npublic class GetTaskVariablesCmd implements Command<Map<String, Object>>, Serializable {\n\n    private static final long serialVersionUID = 1L;\n    protected String taskId;\n    protected Collection<String> variableNames;\n    protected boolean isLocal;\n\n    public GetTaskVariablesCmd(String taskId, Collection<String> variableNames, boolean isLocal) {\n        this.taskId = taskId;\n        this.variableNames = variableNames;\n        this.isLocal = isLocal;\n    }\n\n    @Override\n    public Map<String, Object> execute(CommandContext commandContext) {\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(\"task \" + taskId + \" doesn't exist\", Task.class);\n        }\n\n        if (variableNames == null) {\n\n            if (isLocal) {\n                return task.getVariablesLocal();\n            } else {\n                return task.getVariables();\n            }\n","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cmd/GetTaskVariablesCmd.java#L29-L65","documentation":"GetTaskVariablesCmd.execute rejects a null taskId with ActivitiIllegalArgumentException before querying the task table. It is the batch (all-variables) counterpart of the single-variable guard. Always a caller-side null-propagation bug.","triggerScenarios":"Calling taskService.getVariables(taskId) or getVariablesLocal(taskId) with null taskId, e.g. when the id field of a task DTO was never populated.","commonSituations":"Deserializing task payloads where taskId was absent; code paths executed before a task was actually created; optional form submissions leaving the id blank.","solutions":["Null-check taskId before calling getVariables/getVariablesLocal.","Trace why the id was null: unbound input, failed deserialization, or an earlier exception swallowed.","Return a client-side validation error instead of hitting the engine.","For optional tasks, query existence first and short-circuit."],"exampleFix":"// before\nMap<String, Object> vars = taskService.getVariables(taskId);\n// after\nObjects.requireNonNull(taskId, \"taskId must not be null\");\nMap<String, Object> vars = taskService.getVariables(taskId);","handlingStrategy":"validation","validationCode":"Objects.requireNonNull(taskId, \"taskId must not be null\");","typeGuard":null,"tryCatchPattern":"try {\n    return taskService.getVariables(taskId);\n} catch (ActivitiIllegalArgumentException e) {\n    return Collections.emptyMap();\n}","preventionTips":["Require taskId in constructors of task-bound services.","Validate DTOs after deserialization so missing ids fail early.","Never call engine APIs with fields that may default to null."],"tags":["null","task","validation"],"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"}