{"record":{"id":"e5f785df6f8d1550","repo":"flowable/flowable-engine","slug":"variables-is-empty-e5f785","errorCode":null,"errorMessage":"variables is empty","messagePattern":"variables is empty","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"warning","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/SetVariablesCmd.java","lineNumber":54,"sourceCode":"    \n    protected String caseInstanceId;\n    protected Map<String, Object> variables;\n    \n    public SetVariablesCmd(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        CaseInstanceEntity caseInstanceEntity = CommandContextUtil.getCaseInstanceEntityManager(commandContext).findById(caseInstanceId);\n        if (caseInstanceEntity == null) {\n            throw new FlowableObjectNotFoundException(\"No case instance found for id \" + caseInstanceId, CaseInstanceEntity.class);\n        }\n        caseInstanceEntity.setVariables(variables);\n        \n        Set<String> variableNames = variables.keySet();\n        \n        CmmnEngineAgenda agenda = CommandContextUtil.getAgenda(commandContext);\n        \n        CmmnDeploymentManager deploymentManager = CommandContextUtil.getCmmnEngineConfiguration(commandContext).getDeploymentManager();\n        CaseDefinition caseDefinition = deploymentManager.findDeployedCaseDefinitionById(caseInstanceEntity.getCaseDefinitionId());\n        boolean evaluateVariableEventListener = false;\n        if (caseDefinition != null) {\n            CmmnModel cmmnModel = deploymentManager.resolveCaseDefinition(caseDefinition).getCmmnModel();\n            for (Case caze : cmmnModel.getCases()) {","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/SetVariablesCmd.java#L36-L72","documentation":"SetVariablesCmd rejects an empty variables map because setting zero variables is a no-op that usually indicates a caller bug. After the null and caseInstanceId checks, an empty map triggers FlowableIllegalArgumentException.","triggerScenarios":"Calling CmmnRuntimeService.setVariables(caseInstanceId, Collections.emptyMap()) or with a map whose entries were all filtered out before the call.","commonSituations":"Building variables conditionally so all keys are removed; passing a deserialized/empty payload from a REST request; looping that ends with nothing left to set.","solutions":["Guard the call: only invoke setVariables when !variables.isEmpty().","Fix upstream logic that produces an empty map (validate request payload keys).","If a no-op is acceptable, check emptiness first and return early."],"exampleFix":"// before\nruntimeService.setVariables(caseInstanceId, variables); // may be empty\n// after\nif (!variables.isEmpty()) {\n    runtimeService.setVariables(caseInstanceId, variables);\n}","handlingStrategy":"validation","validationCode":"if (variables == null || variables.isEmpty()) return; // no-op guard","typeGuard":null,"tryCatchPattern":"try {\n    runtimeService.setVariables(caseInstanceId, vars);\n} catch (FlowableIllegalArgumentException e) {\n    if (e.getMessage().contains(\"variables is empty\")) {\n        // treat as no-op\n    }\n}","preventionTips":["Guard with !map.isEmpty() before calling setVariables","Validate that payload parsing actually produced keys","Log when a variable update is skipped due to emptiness"],"tags":["cmmn","variables","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-14T05:17:10.506Z"}