{"record":{"id":"004949cbb57dcd9d","repo":"flowable/flowable-engine","slug":"taskid-is-null-004949","errorCode":null,"errorMessage":"taskId is null","messagePattern":"taskId is null","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/GetTaskVariableInstancesCmd.java","lineNumber":47,"sourceCode":"\npublic class GetTaskVariableInstancesCmd implements Command<Map<String, VariableInstance>>, Serializable {\n\n    private static final long serialVersionUID = 1L;\n    \n    protected String taskId;\n    protected Collection<String> variableNames;\n    protected boolean isLocal;\n\n    public GetTaskVariableInstancesCmd(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, VariableInstance> execute(CommandContext commandContext) {\n        if (taskId == null) {\n            throw new FlowableIllegalArgumentException(\"taskId is null\");\n        }\n\n        CmmnEngineConfiguration cmmnEngineConfiguration = CommandContextUtil.getCmmnEngineConfiguration(commandContext);\n        TaskEntity task = cmmnEngineConfiguration.getTaskServiceConfiguration().getTaskService().getTask(taskId);\n\n        if (task == null) {\n            throw new FlowableObjectNotFoundException(\"task \" + taskId + \" doesn't exist\", Task.class);\n        }\n\n        Map<String, VariableInstance> variables = null;\n        if (variableNames == null) {\n\n            if (isLocal) {\n                variables = task.getVariableInstancesLocal();\n            } else {\n                variables = task.getVariableInstances();\n            }\n","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/GetTaskVariableInstancesCmd.java#L29-L65","documentation":"GetTaskVariableInstancesCmd.execute() validates that a taskId was supplied before retrieving all variable instances for the task. A null taskId throws FlowableIllegalArgumentException('taskId is null') because the map of variables cannot be resolved without a task identifier.","triggerScenarios":"Calling cmmnTaskService.getVariableInstances(null) or getVariableInstancesLocal(null, variableNames); building GetTaskVariableInstancesCmd with a null id and executing it.","commonSituations":"Batch worker iterating task ids where one entry is null; task id extracted from an optional message/header that was absent; variable-scope resolution helper invoked without a bound task.","solutions":["Check taskId for null before calling getVariableInstances/getVariableInstancesLocal.","Filter null/blank entries out of any id collection before iterating and calling the API per id.","Fix the upstream source (query result, header, form data) that failed to supply the task id."],"exampleFix":"// before\nMap<String, VariableInstance> vars = cmmnTaskService.getVariableInstances(taskId);\n// after\nif (taskId != null) {\n    Map<String, VariableInstance> vars = cmmnTaskService.getVariableInstances(taskId);\n}","handlingStrategy":"validation","validationCode":"if (taskId == null) { throw new IllegalArgumentException(\"taskId is required\"); }","typeGuard":"boolean isValidTaskId(String taskId) { return taskId != null && !taskId.isEmpty(); }","tryCatchPattern":"try { return taskService.getVariableInstances(taskId); } catch (FlowableIllegalArgumentException e) { return Collections.emptyMap(); }","preventionTips":["Filter null entries out of id collections before batch loops","Treat optional task references explicitly (Optional<String>)","Log the origin of the task id to trace null propagation"],"tags":["flowable","cmmn","null-argument","task-variables"],"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"}