{"record":{"id":"f96444b5188fc37b","repo":"flowable/flowable-engine","slug":"caseinstanceid-is-null-f96444","errorCode":null,"errorMessage":"caseInstanceId is null","messagePattern":"caseInstanceId 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":38,"sourceCode":"import org.flowable.common.engine.api.FlowableIllegalArgumentException;\nimport org.flowable.common.engine.api.FlowableObjectNotFoundException;\nimport org.flowable.common.engine.impl.interceptor.Command;\nimport 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        }","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/SetVariablesAsyncCmd.java#L20-L56","documentation":"Thrown by SetVariablesAsyncCmd.execute when caseInstanceId is null. The bulk async variable setter validates the case instance id before the null/emptiness checks on the variables map and rejects null ids with FlowableIllegalArgumentException.","triggerScenarios":"Calling setVariablesAsync with a null id, or constructing SetVariablesAsyncCmd without initializing caseInstanceId.","commonSituations":"Id lost between service layers, earlier query returned null unchecked, REST payload omitted the id field.","solutions":["Ensure caseInstanceId is set before calling setVariablesAsync","Validate the id non-null/non-empty at the boundary of your service","Fix the producer of the id that returned null"],"exampleFix":"// before\ncmmnRuntimeService.setVariablesAsync(caseInstanceId, vars);\n// after\nObjects.requireNonNull(caseInstanceId, \"caseInstanceId required\");\ncmmnRuntimeService.setVariablesAsync(caseInstanceId, vars);","handlingStrategy":"validation","validationCode":"if (caseInstanceId == null || caseInstanceId.trim().isEmpty()) {\n    throw new IllegalArgumentException(\"caseInstanceId must not be null or empty\");\n}","typeGuard":"boolean hasCaseInstanceId(String id) { return id != null && !id.trim().isEmpty(); }","tryCatchPattern":"try {\n    cmmnRuntimeService.setVariablesAsync(caseInstanceId, vars);\n} catch (FlowableIllegalArgumentException e) {\n    log.error(\"Invalid argument for setVariablesAsync: {}\", e.getMessage());\n}","preventionTips":["Assert id non-null at the entry point of bulk variable updates","Bind REST/DTO fields with required validation annotations","Capture case start results so ids are never lost"],"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-14T11:17:12.474Z"}