{"record":{"id":"c4da72d4c9728002","repo":"flowable/flowable-engine","slug":"case-instance-doesn-t-exist-c4da72","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/GetCaseVariableInstancesCmd.java","lineNumber":48,"sourceCode":"    \n    protected String caseInstanceId;\n\n    public GetCaseVariableInstancesCmd(String caseInstanceId) {\n        this.caseInstanceId = caseInstanceId;\n    }\n\n    @Override\n    public Map<String, VariableInstance> execute(CommandContext commandContext) {\n\n        // Verify existence of execution\n        if (caseInstanceId == null) {\n            throw new FlowableIllegalArgumentException(\"caseInstanceId is null\");\n        }\n\n        CaseInstanceEntity caseInstance = CommandContextUtil.getCaseInstanceEntityManager(commandContext).findById(caseInstanceId);\n\n        if (caseInstance == null) {\n            throw new FlowableObjectNotFoundException(\"case instance \" + caseInstanceId + \" doesn't exist\", CaseInstance.class);\n        }\n\n        return caseInstance.getVariableInstances();\n    }\n}\n","sourceCodeStart":30,"sourceCodeEnd":54,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/GetCaseVariableInstancesCmd.java#L30-L54","documentation":"GetCaseVariableInstancesCmd loads the case instance by id using the CaseInstanceEntityManager. When findById returns null, meaning no runtime case instance matches the id, Flowable throws FlowableObjectNotFoundException typed to CaseInstance. The double space in 'case instance  doesn't exist' reflects the message being built without embedding the id in this variant.","triggerScenarios":"caseService.getVariables(caseInstanceId) with an id of a case instance that does not exist in the runtime tables (completed, deleted, different DB, or wrong id).","commonSituations":"Querying variables after case completion (runtime data gone); multi-environment id mix-ups; pointing the API at a fresh/cleared database; stale cached ids in a frontend.","solutions":["Confirm the case instance exists via a caseInstanceQuery before fetching variables","Use the history service (HistoricCaseInstance) if the case already completed","Verify engine datasource matches where the case instance was created","Re-check/correct the caseInstanceId value"],"exampleFix":"// before\nMap<String, VariableInstance> vars = caseService.getVariableInstances(caseInstanceId);\n// after\nCaseInstance ci = caseService.createCaseInstanceQuery().caseInstanceId(caseInstanceId).singleResult();\nif (ci == null) {\n    // fall back to history\n    HistoricCaseInstance hci = historyService.createHistoricCaseInstanceQuery().caseInstanceId(caseInstanceId).singleResult();\n} else {\n    Map<String, VariableInstance> vars = caseService.getVariableInstances(caseInstanceId);\n}","handlingStrategy":"validation","validationCode":"if (caseService.createCaseInstanceQuery().caseInstanceId(id).count() == 0) { /* not found path */ }","typeGuard":null,"tryCatchPattern":"try { return caseService.getVariables(caseInstanceId); } catch (FlowableObjectNotFoundException e) { return Collections.emptyMap(); }","preventionTips":["Verify runtime existence before reading variables","Fall back to HistoricCaseInstance for completed cases","Avoid caching runtime ids longer than the case lifetime"],"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"}