{"record":{"id":"3ab94c27a3bdadcc","repo":"flowable/flowable-engine","slug":"variables-is-null-3ab94c","errorCode":null,"errorMessage":"variables is null","messagePattern":"variables is null","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/SetVariablesAsyncCmd.java","lineNumber":41,"sourceCode":"import org.flowable.common.engine.impl.interceptor.CommandContext;\n\npublic class SetVariablesAsyncCmd extends AbstractSetVariableAsyncCmd implements Command<Void> {\n    \n    protected String caseInstanceId;\n    protected Map<String, Object> variables;\n    \n    public SetVariablesAsyncCmd(String caseInstanceId, Map<String, Object> variables) {\n        this.caseInstanceId = caseInstanceId;\n        this.variables = variables;\n    }\n    \n    @Override\n    public Void execute(CommandContext commandContext) {\n        if (caseInstanceId == null) {\n            throw new FlowableIllegalArgumentException(\"caseInstanceId is null\");\n        }\n        if (variables == null) {\n            throw new FlowableIllegalArgumentException(\"variables is null\");\n        }\n        if (variables.isEmpty()) {\n            throw new FlowableIllegalArgumentException(\"variables is empty\");\n        }\n     \n        CmmnEngineConfiguration cmmnEngineConfiguration = CommandContextUtil.getCmmnEngineConfiguration(commandContext);\n        CaseInstanceEntity caseInstanceEntity = cmmnEngineConfiguration.getCaseInstanceEntityManager().findById(caseInstanceId);\n        if (caseInstanceEntity == null) {\n            throw new FlowableObjectNotFoundException(\"No case instance found for id \" + caseInstanceId, CaseInstanceEntity.class);\n        }\n        \n        for (String variableName : variables.keySet()) {\n            addVariable(false, caseInstanceId, null, variableName, variables.get(variableName), caseInstanceEntity.getTenantId(), \n                    cmmnEngineConfiguration.getVariableServiceConfiguration().getVariableService());\n        }\n        \n        createSetAsyncVariablesJob(caseInstanceEntity, cmmnEngineConfiguration);\n        ","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/SetVariablesAsyncCmd.java#L23-L59","documentation":"Thrown by SetVariablesAsyncCmd.execute when the variables map is null. After checking the case instance id, the command validates the variables argument; null maps are rejected with FlowableIllegalArgumentException since there is nothing to schedule for the async job.","triggerScenarios":"Calling setVariablesAsync(caseInstanceId, null) or passing a map field never initialized.","commonSituations":"Deserialization of an empty/absent JSON payload yielding null, refactoring left the map unassigned.","solutions":["Pass a non-null map (even an empty one if allowed, but note empty also throws)","Initialize the variables map before the call","Fix the deserialization/binding that produced null"],"exampleFix":"// before\ncmmnRuntimeService.setVariablesAsync(caseId, vars); // vars may be null\n// after\nMap<String, Object> vars = payload.getVars();\nif (vars == null || vars.isEmpty()) throw new IllegalArgumentException(\"variables required\");\ncmmnRuntimeService.setVariablesAsync(caseId, vars);","handlingStrategy":"validation","validationCode":"if (variables == null || variables.isEmpty()) {\n    throw new IllegalArgumentException(\"variables map must be non-null and non-empty\");\n}","typeGuard":"boolean hasVariables(Map<String, Object> vars) { return vars != null && !vars.isEmpty(); }","tryCatchPattern":"try {\n    cmmnRuntimeService.setVariablesAsync(caseInstanceId, vars);\n} catch (FlowableIllegalArgumentException e) {\n    log.error(\"Invalid variables argument: {}\", e.getMessage());\n}","preventionTips":["Default-initialize variable maps (new HashMap<>()) rather than leaving them null","Validate deserialized payloads before passing maps to the engine","Test code paths where payloads omit the variables field"],"tags":["flowable","cmmn","null-check","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-14T05:17:10.506Z"}