{"record":{"id":"63ea2d602e3b718a","repo":"flowable/flowable-engine","slug":"variables-is-empty-63ea2d","errorCode":null,"errorMessage":"variables is empty","messagePattern":"variables is empty","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":44,"sourceCode":"    \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        \n        return null;\n    }\n","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/SetVariablesAsyncCmd.java#L26-L62","documentation":"Thrown by SetVariablesAsyncCmd.execute when the variables map is non-null but empty. The command requires at least one variable to write, so an empty map is rejected with FlowableIllegalArgumentException to avoid scheduling a pointless async job.","triggerScenarios":"Calling setVariablesAsync with an empty Map, typically from a filtered/transformed collection that ended up with zero entries.","commonSituations":"Input payload with no variables, all entries filtered out by validation logic, batch job iterating over cases with nothing to set.","solutions":["Skip the call when the map is empty instead of invoking the API","Validate map non-empty before calling and fail earlier with a clearer message","Fix the upstream collection building so it produces the expected entries"],"exampleFix":"// before\nif (!vars.isEmpty()) {\n    cmmnRuntimeService.setVariablesAsync(caseId, vars);\n}\n// after (explicit guard at the API boundary)\nif (vars == null || vars.isEmpty()) {\n    throw new IllegalArgumentException(\"At least one variable is required\");\n}\ncmmnRuntimeService.setVariablesAsync(caseId, vars);","handlingStrategy":"validation","validationCode":"if (variables == null || variables.isEmpty()) {\n    throw new IllegalArgumentException(\"At least one variable is required\");\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(\"No variables provided: {}\", e.getMessage());\n}","preventionTips":["Skip the engine call entirely when there is nothing to set","Log/review filtering logic that can drain the map to zero entries","Add early guards in batch jobs so empty updates fail before job scheduling"],"tags":["flowable","cmmn","empty-collection","validation"],"backgroundTag":"empty-required-field","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}