{"record":{"id":"217c7448cfb02a62","repo":"flowable/flowable-engine","slug":"could-not-find-a-case-instance","errorCode":null,"errorMessage":"Could not find a case instance","messagePattern":"Could not find a case instance","errorType":"http","errorClass":"FlowableObjectNotFoundException","httpStatus":404,"severity":"error","filePath":"modules/flowable-cmmn-rest/src/main/java/org/flowable/cmmn/rest/service/api/runtime/caze/BaseVariableResource.java","lineNumber":86,"sourceCode":"    }\n\n    protected PlanItemInstance getPlanItemInstanceFromRequest(String planItemInstanceId) {\n        PlanItemInstance planItemInstance = runtimeService.createPlanItemInstanceQuery().planItemInstanceId(planItemInstanceId).singleResult();\n        if (planItemInstance == null) {\n            throw new FlowableObjectNotFoundException(\"Could not find a plan item instance with id '\" + planItemInstanceId + \"'.\");\n        }\n\n        if (restApiInterceptor != null) {\n            restApiInterceptor.accessPlanItemInstanceInfoById(planItemInstance);\n        }\n\n        return planItemInstance;\n    }\n\n    public RestVariable getVariableFromRequest(CaseInstance caseInstance, String variableName, boolean includeBinary) {\n\n        if (caseInstance == null) {\n            throw new FlowableObjectNotFoundException(\"Could not find a case instance\", CaseInstance.class);\n        }\n\n        if (restApiInterceptor != null) {\n            restApiInterceptor.accessCaseInstanceVariable(caseInstance, variableName);\n        }\n\n        return getVariableFromRequestWithoutAccessCheck(caseInstance.getId(), variableName, CmmnRestResponseFactory.VARIABLE_CASE, includeBinary);\n    }\n\n    public RestVariable getVariableFromRequest(PlanItemInstance planItemInstance, String variableName, boolean includeBinary) {\n        if (planItemInstance == null) {\n            throw new FlowableObjectNotFoundException(\"Could not find a plan item instance\", CaseInstance.class);\n        }\n\n        if (restApiInterceptor != null) {\n            restApiInterceptor.accessPlanItemInstanceVariable(planItemInstance, variableName);\n        }\n        return getVariableFromRequestWithoutAccessCheck(planItemInstance.getId(), variableName, CmmnRestResponseFactory.VARIABLE_PLAN_ITEM, includeBinary);","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-rest/src/main/java/org/flowable/cmmn/rest/service/api/runtime/caze/BaseVariableResource.java#L68-L104","documentation":"This overload of getVariableFromRequest requires a non-null CaseInstance; passing null throws FlowableObjectNotFoundException with the message 'Could not find a case instance'. It guards callers that resolved a case instance earlier and got nothing.","triggerScenarios":"Invoking the public getVariableFromRequest(CaseInstance, String, boolean) — typically via the REST 'variable' endpoint — after the case instance lookup returned null (nonexistent or completed case instance id).","commonSituations":"Requesting variables of a case instance that has already ended (moved to history); wrong caseInstanceId path parameter; ids from another database.","solutions":["Confirm the case instance is still running via a case-instance query before fetching variables","Use the case history service for completed case instances' variables","Fix the caseInstanceId path parameter"],"exampleFix":"// before\nrestVariable = getVariableFromRequest(null, variableName, false); // lookup failed upstream\n// after\nif (caseInstance == null) throw notFound; // resolve valid CaseInstance first\nrestVariable = getVariableFromRequest(caseInstance, variableName, false);","handlingStrategy":"try-catch","validationCode":"const ci = await fetch(`/cmmn-runtime/case-instances/${caseId}`);\nif (!ci.ok) throw new Error('Case instance not running: ' + caseId);","typeGuard":"if (caseInstance == null) { /* treat as not-found before calling */ }","tryCatchPattern":"try { ... } catch (e) {\n  if (e instanceof FlowableObjectNotFoundException) { /* check history for ended case */ }\n}","preventionTips":["Verify the case instance is active before reading variables","Use history endpoints for completed cases","Store correct case instance ids with their database context"],"tags":["rest-api","case-instance","not-found","variables"],"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-14T11:17:12.474Z"}