{"record":{"id":"498e6e781872e090","repo":"flowable/flowable-engine","slug":"could-not-find-a-case-instance-with-id-caseinst-498e6e","errorCode":null,"errorMessage":"Could not find a case instance with id '${caseInstanceId}'.","messagePattern":"Could not find a case instance with id '(.+?)'\\.","errorType":"http","errorClass":"FlowableObjectNotFoundException","httpStatus":404,"severity":"error","filePath":"modules/flowable-cmmn-rest/src/main/java/org/flowable/cmmn/rest/service/api/runtime/caze/BaseCaseInstanceResource.java","lineNumber":295,"sourceCode":"     */\n    protected CaseInstance getCaseInstanceFromRequest(String caseInstanceId) {\n        CaseInstance caseInstance = getCaseInstanceFromRequestWithoutAccessCheck(caseInstanceId);\n\n        if (restApiInterceptor != null) {\n            restApiInterceptor.accessCaseInstanceInfoById(caseInstance);\n        }\n\n        return caseInstance;\n    }\n\n    /**\n     * Returns the {@link CaseInstance} that is requested without calling the access interceptor\n     * Throws the right exceptions when bad request was made or instance was not found.\n     */\n    protected CaseInstance getCaseInstanceFromRequestWithoutAccessCheck(String caseInstanceId) {\n        CaseInstance caseInstance = runtimeService.createCaseInstanceQuery().caseInstanceId(caseInstanceId).singleResult();\n        if (caseInstance == null) {\n            throw new FlowableObjectNotFoundException(\"Could not find a case instance with id '\" + caseInstanceId + \"'.\");\n        }\n\n        return caseInstance;\n    }\n\n    protected void addVariables(CaseInstanceQuery caseInstanceQuery, List<QueryVariable> variables) {\n        for (QueryVariable variable : variables) {\n            if (variable.getVariableOperation() == null) {\n                throw new FlowableIllegalArgumentException(\"Variable operation is missing for variable: \" + variable.getName());\n            }\n            if (variable.getVariableOperation() != QueryVariableOperation.EXISTS && variable.getVariableOperation() != QueryVariableOperation.NOT_EXISTS) {\n                if (variable.getValue() == null) {\n                    throw new FlowableIllegalArgumentException(\"Variable value is missing for variable: \" + variable.getName());\n                }\n            }\n\n            boolean nameLess = variable.getName() == null;\n","sourceCodeStart":277,"sourceCodeEnd":313,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-rest/src/main/java/org/flowable/cmmn/rest/service/api/runtime/caze/BaseCaseInstanceResource.java#L277-L313","documentation":"getCaseInstanceFromRequestWithoutAccessCheck queries the runtime service for a case instance by id; if the query returns null, it throws FlowableObjectNotFoundException. This means no running case instance with the given id exists at query time.","triggerScenarios":"Any case-instance endpoint (GET /cmmn-query/runtime/case-instances/{caseInstanceId}, etc.) with an id that does not exist, was already completed/terminated, or belongs to another database/tenant.","commonSituations":"Case finished and moved to history (runtime row deleted) while client still queries runtime endpoints, typos in ids, pointing the client at a different DB/tenant, or hard-deleted test data.","solutions":["Query the history endpoint (/cmmn-query/history/historic-case-instances/{id}) if the case is completed.","Verify the caseInstanceId against the list endpoint or the CMMN engine database.","Confirm the REST app points to the same database/tenant where the case was started.","Catch FlowableObjectNotFoundException and return/handle 404 in the caller."],"exampleFix":"// before\nget('/cmmn-query/runtime/case-instances/' + id); // 404 for finished cases\n\n// after\nlet c = get('/cmmn-query/runtime/case-instances/' + id);\nif (c.status === 404) c = get('/cmmn-query/history/historic-case-instances/' + id);","handlingStrategy":"try-catch","validationCode":"// verify id exists in runtime before use\nconst running = await get(`/cmmn-query/runtime/case-instances/${id}`); // 404 => use history","typeGuard":null,"tryCatchPattern":"try {\n  return caseInstanceApi.get(caseInstanceId);\n} catch (FlowableObjectNotFoundException e) {\n  return historicCaseInstanceApi.get(caseInstanceId); // fallback to history\n}","preventionTips":["Fall back to history endpoints for completed cases.","Verify ids against the environment/tenant you query.","Treat 404 on runtime queries as normal lifecycle, not a bug."],"tags":["rest-api","case-instance","not-found","flowable"],"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"}