{"record":{"id":"bc9d7ce11524ce83","repo":"flowable/flowable-engine","slug":"taskid-is-null-bc9d7c","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/GetTaskVariablesCmd.java","lineNumber":50,"sourceCode":" */\npublic class GetTaskVariablesCmd implements Command<Map<String, Object>>, 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 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 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        if (variableNames == null) {\n\n            if (isLocal) {\n                return task.getVariablesLocal();\n            } else {\n                return task.getVariables();\n            }\n\n        } else {","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/GetTaskVariablesCmd.java#L32-L68","documentation":"GetTaskVariablesCmd.execute() is the fail-fast guard for the typed variable map API: with a null taskId it throws FlowableIllegalArgumentException('taskId is null'), since no variable map can be built without a task identifier.","triggerScenarios":"Calling cmmnTaskService.getVariables(null) or getVariablesLocal(null, variableNames/isLocal variants); executing a directly constructed GetTaskVariablesCmd with a null id.","commonSituations":"Null propagated from an optional lookup (e.g. Map.get returning null used as the task id); deserialized DTO with a missing id field; integration code where the assignment step was skipped so no task id was captured.","solutions":["Null-check the taskId before calling getVariables/getVariablesLocal.","Assert the id was produced by a prior task-creation/query step before using it.","Log and skip tasks with missing ids in batch loops instead of passing null through."],"exampleFix":"// before\nMap<String, Object> vars = cmmnTaskService.getVariables(taskId);\n// after\nObjects.requireNonNull(taskId, \"taskId must not be null\");\nMap<String, Object> vars = cmmnTaskService.getVariables(taskId);","handlingStrategy":"validation","validationCode":"Objects.requireNonNull(taskId, \"taskId must not be null\");","typeGuard":"boolean taskIdPresent(String taskId) { return taskId != null; }","tryCatchPattern":"try { return taskService.getVariables(taskId); } catch (FlowableIllegalArgumentException e) { log.error(\"taskId missing: {}\", e.getMessage()); throw e; }","preventionTips":["Fail fast on null ids at the edge of your service layer","Capture the id from startCaseInstance/createTask return values immediately","Use static analysis or @NonNull annotations to catch null flow"],"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"}