{"record":{"id":"670b09dcb2299a01","repo":"flowable/flowable-engine","slug":"caseinstanceid-is-null-670b09","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/GetCaseVariableInstanceCmd.java","lineNumber":42,"sourceCode":"import org.flowable.common.engine.impl.interceptor.CommandContext;\nimport org.flowable.variable.api.persistence.entity.VariableInstance;\n\npublic class GetCaseVariableInstanceCmd implements Command<VariableInstance>, Serializable {\n\n    private static final long serialVersionUID = 1L;\n    \n    protected String caseInstanceId;\n    protected String variableName;\n\n    public GetCaseVariableInstanceCmd(String caseInstanceId, String variableName) {\n        this.caseInstanceId = caseInstanceId;\n        this.variableName = variableName;\n    }\n\n    @Override\n    public VariableInstance execute(CommandContext commandContext) {\n        if (caseInstanceId == null) {\n            throw new FlowableIllegalArgumentException(\"caseInstanceId is null\");\n        }\n        if (variableName == null) {\n            throw new FlowableIllegalArgumentException(\"variableName is null\");\n        }\n\n        CmmnEngineConfiguration cmmnEngineConfiguration = CommandContextUtil.getCmmnEngineConfiguration(commandContext);\n        CaseInstanceEntity caseInstance = cmmnEngineConfiguration.getCaseInstanceEntityManager().findById(caseInstanceId);\n\n        if (caseInstance == null) {\n            throw new FlowableObjectNotFoundException(\"case instance \" + caseInstanceId + \" doesn't exist\", CaseInstance.class);\n        }\n\n        return caseInstance.getVariableInstance(variableName, false);\n    }\n}\n","sourceCodeStart":24,"sourceCodeEnd":58,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/GetCaseVariableInstanceCmd.java#L24-L58","documentation":"FlowableIllegalArgumentException thrown by GetCaseVariableInstanceCmd.execute when caseInstanceId is null. The command needs a case instance id to look up the variable instance for the given variable name. This is a leading argument-validation guard before any query runs.","triggerScenarios":"Calling caseService.getCaseVariableInstance(null, variableName) or variableInstance queries built through the service with an unset caseInstanceId.","commonSituations":"Variable passed from an unset request parameter or path variable; id lost when chaining calls across services; generic variable-lookup helper invoked before the case instance was created.","solutions":["Pass a valid non-null caseInstanceId to getCaseVariableInstance","Validate the id in the caller before invoking the engine","Resolve the case instance id from the business key or execution context if it was never supplied"],"exampleFix":"// before\nVariableInstance vi = caseService.getCaseVariableInstance(caseInstanceId, varName);\n// after\nif (caseInstanceId != null) {\n    VariableInstance vi = caseService.getCaseVariableInstance(caseInstanceId, varName);\n}","handlingStrategy":"validation","validationCode":"if (caseInstanceId == null || variableName == null) throw new IllegalArgumentException(\"caseInstanceId and variableName are required\");","typeGuard":"boolean hasCaseId = caseInstanceId instanceof String && !((String) caseInstanceId).isEmpty();","tryCatchPattern":null,"preventionTips":["Validate required ids at your service boundary before engine calls","Resolve case instance ids before variable lookup helpers run"],"tags":["cmmn","variables","null-argument","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"}