{"record":{"id":"f716be75f4212ddc","repo":"flowable/flowable-engine","slug":"taskid-is-null-f716be","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/GetTaskVariableInstanceCmd.java","lineNumber":45,"sourceCode":"\npublic class GetTaskVariableInstanceCmd implements Command<VariableInstance>, Serializable {\n\n    private static final long serialVersionUID = 1L;\n    \n    protected String taskId;\n    protected String variableName;\n    protected boolean isLocal;\n\n    public GetTaskVariableInstanceCmd(String taskId, String variableName, boolean isLocal) {\n        this.taskId = taskId;\n        this.variableName = variableName;\n        this.isLocal = isLocal;\n    }\n\n    @Override\n    public VariableInstance execute(CommandContext commandContext) {\n        if (taskId == null) {\n            throw new FlowableIllegalArgumentException(\"taskId is null\");\n        }\n        if (variableName == null) {\n            throw new FlowableIllegalArgumentException(\"variableName 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        VariableInstance variableEntity;\n\n        if (isLocal) {\n            variableEntity = task.getVariableInstanceLocal(variableName, false);\n        } else {\n            variableEntity = task.getVariableInstance(variableName, false);","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/GetTaskVariableInstanceCmd.java#L27-L63","documentation":"GetTaskVariableInstanceCmd.execute() validates its command arguments before doing any work. When the taskId passed to the command is null, it throws FlowableIllegalArgumentException('taskId is null') because a task variable instance cannot be looked up without a task id. This is a fail-fast guard protecting the downstream task service query from a pointless or dangerous null lookup.","triggerScenarios":"Calling CmmnTaskService.getVariableInstance(taskId, variableName) or getVariableInstanceLocal(taskId, variableName) with a null taskId; constructing GetTaskVariableInstanceCmd(null, name, isLocal) directly and executing it.","commonSituations":"taskId obtained from an unresolved/failed prior API call (e.g. task == null from a createTask/query result) and passed on unguarded; a Map- or form-sourced task id that was never populated; refactoring that dropped a null check between fetching and using the id.","solutions":["Ensure a non-null taskId is passed: verify the value before calling taskService.getVariableInstance/getVariableInstanceLocal.","If the taskId came from a previous query result, check that result for null/empty before using it.","Fix the upstream data source (form field, process variable, request parameter) that produced a missing task id."],"exampleFix":"// before\nVariableInstance vi = cmmnTaskService.getVariableInstance(taskId, \"status\");\n// after\nif (taskId == null) {\n    throw new IllegalArgumentException(\"taskId must be resolved before fetching variables\");\n}\nVariableInstance vi = cmmnTaskService.getVariableInstance(taskId, \"status\");","handlingStrategy":"validation","validationCode":"if (taskId == null || taskId.isEmpty()) { throw new IllegalArgumentException(\"taskId is required\"); }","typeGuard":"boolean hasTaskId(String taskId) { return taskId != null && !taskId.isEmpty(); }","tryCatchPattern":"try { return taskService.getVariableInstance(taskId, name); } catch (FlowableIllegalArgumentException e) { log.error(\"Bad argument: {}\", e.getMessage()); throw e; }","preventionTips":["Resolve task ids from authoritative query results, never from nullable maps/params","Add Objects.requireNonNull checks at API boundaries","Use IDE null-analysis (@NonNull) on service method parameters"],"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"}