{"record":{"id":"8a5f7df4822a9beb","repo":"flowable/flowable-engine","slug":"case-instance-doesn-t-exist","errorCode":null,"errorMessage":"case instance  doesn't exist","messagePattern":"case instance  doesn't exist","errorType":"exception","errorClass":"FlowableObjectNotFoundException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/GetCaseVariableInstanceCmd.java","lineNumber":52,"sourceCode":"    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":34,"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#L34-L58","documentation":"After validating inputs, GetCaseVariableInstanceCmd loads the case instance by id via the CaseInstanceEntityManager. If no case instance exists for the given id, it throws FlowableObjectNotFoundException with CaseInstance.class as the type. The message deliberately contains the id followed by ' doesn't exist' (note the double space in the raw concatenation, the id is null/empty in the text when missing).","triggerScenarios":"caseService.getVariableInstance(caseInstanceId, variableName) where caseInstanceId does not match any persisted case instance (already terminated/removed, wrong engine/database, or typo in id).","commonSituations":"Looking up variables of a case instance that completed and was cleaned up; pointing client at a different database/schema than the engine; copying an id from another environment; historic vs runtime id confusion.","solutions":["Verify the caseInstanceId exists: query the case instance or runtime service first","Check the engine is connected to the same database/schema where the case was created","Confirm the case instance has not been completed/removed (check history service instead)","Correct any id typo or stale id stored by the caller"],"exampleFix":"// before\nVariableInstance vi = caseService.getVariableInstance(caseInstanceId, \"status\");\n// after\nCaseInstance ci = caseService.createCaseInstanceQuery().caseInstanceId(caseInstanceId).singleResult();\nif (ci != null) {\n    VariableInstance vi = caseService.getVariableInstance(caseInstanceId, \"status\");\n}","handlingStrategy":"validation","validationCode":"boolean exists = caseService.createCaseInstanceQuery().caseInstanceId(id).count() > 0;","typeGuard":null,"tryCatchPattern":"try { return caseService.getVariableInstance(caseInstanceId, variableName); } catch (FlowableObjectNotFoundException e) { log.warn(\"Case instance {} not found\", caseInstanceId); return null; }","preventionTips":["Check existence with a query before variable access","Use the history service for completed cases","Confirm all environments point at the same datasource"],"tags":["java","flowable","not-found","case-instance"],"backgroundTag":"entity-not-found","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"}