{"record":{"id":"4d67dd7f06450c17","repo":"flowable/flowable-engine","slug":"taskid-is-null-4d67dd","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/HasTaskVariableCmd.java","lineNumber":47,"sourceCode":" */\npublic class HasTaskVariableCmd implements Command<Boolean>, 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 HasTaskVariableCmd(String taskId, String variableName, boolean isLocal) {\n        this.taskId = taskId;\n        this.variableName = variableName;\n        this.isLocal = isLocal;\n    }\n\n    @Override\n    public Boolean 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        boolean hasVariable = false;\n\n        if (isLocal) {\n            hasVariable = task.hasVariableLocal(variableName);\n        } else {\n            hasVariable = task.hasVariable(variableName);\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/HasTaskVariableCmd.java#L29-L65","documentation":"HasTaskVariableCmd.execute throws FlowableIllegalArgumentException when taskId is null. The command delegates variable lookup to the task service, which requires a concrete task id; a null id is rejected before the task is fetched.","triggerScenarios":"Calling cmmnTaskService.hasVariable(null, variableName) or hasVariableLocal(null, variableName), or constructing the command with a null taskId (e.g. from a Task object that was never assigned an id).","commonSituations":"Task id obtained from a listener before the task entity was persisted, an uninitialized field in custom command code, or upstream query returning null task.","solutions":["Ensure the task id is populated (persist/fetch the Task first) before calling","Guard the call site with a null check on taskId","Resolve the task via a TaskQuery and handle no-match before reading variables"],"exampleFix":"// before\nboolean has = taskService.hasVariable(taskId, \"priority\");\n// after\nif (taskId != null) {\n    boolean has = taskService.hasVariable(taskId, \"priority\");\n}","handlingStrategy":"validation","validationCode":"if (taskId == null) {\n    throw new IllegalArgumentException(\"taskId is required for hasVariable\");\n}","typeGuard":"boolean hasTaskId(String id) {\n    return id != null && !id.isEmpty();\n}","tryCatchPattern":"try {\n    return taskService.hasVariable(taskId, variableName);\n} catch (FlowableIllegalArgumentException e) {\n    log.warn(\"Invalid hasVariable args: {}\", e.getMessage());\n    return false;\n}","preventionTips":["Only pass ids from persisted Task entities (task.getId() after creation/query)","Null-check upstream query results before variable access","Centralize task-variable access behind a validated helper"],"tags":["flowable","cmmn","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-14T05:17:10.506Z"}