flowable/flowable-engine · error · FlowableObjectNotFoundException
Could not find a case instance with id '${caseInstanceId}'.
Error message
Could not find a case instance with id '${caseInstanceId}'. What it means
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.
Source
Thrown at modules/flowable-cmmn-rest/src/main/java/org/flowable/cmmn/rest/service/api/runtime/caze/BaseCaseInstanceResource.java:295
*/
protected CaseInstance getCaseInstanceFromRequest(String caseInstanceId) {
CaseInstance caseInstance = getCaseInstanceFromRequestWithoutAccessCheck(caseInstanceId);
if (restApiInterceptor != null) {
restApiInterceptor.accessCaseInstanceInfoById(caseInstance);
}
return caseInstance;
}
/**
* Returns the {@link CaseInstance} that is requested without calling the access interceptor
* Throws the right exceptions when bad request was made or instance was not found.
*/
protected CaseInstance getCaseInstanceFromRequestWithoutAccessCheck(String caseInstanceId) {
CaseInstance caseInstance = runtimeService.createCaseInstanceQuery().caseInstanceId(caseInstanceId).singleResult();
if (caseInstance == null) {
throw new FlowableObjectNotFoundException("Could not find a case instance with id '" + caseInstanceId + "'.");
}
return caseInstance;
}
protected void addVariables(CaseInstanceQuery caseInstanceQuery, List<QueryVariable> variables) {
for (QueryVariable variable : variables) {
if (variable.getVariableOperation() == null) {
throw new FlowableIllegalArgumentException("Variable operation is missing for variable: " + variable.getName());
}
if (variable.getVariableOperation() != QueryVariableOperation.EXISTS && variable.getVariableOperation() != QueryVariableOperation.NOT_EXISTS) {
if (variable.getValue() == null) {
throw new FlowableIllegalArgumentException("Variable value is missing for variable: " + variable.getName());
}
}
boolean nameLess = variable.getName() == null;
View on GitHub (pinned to d6d39ce1c6)
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.
Example fix
// before
get('/cmmn-query/runtime/case-instances/' + id); // 404 for finished cases
// after
let c = get('/cmmn-query/runtime/case-instances/' + id);
if (c.status === 404) c = get('/cmmn-query/history/historic-case-instances/' + id); Defensive patterns
Strategy: try-catch
Validate before calling
// verify id exists in runtime before use
const running = await get(`/cmmn-query/runtime/case-instances/${id}`); // 404 => use history Try / catch
try {
return caseInstanceApi.get(caseInstanceId);
} catch (FlowableObjectNotFoundException e) {
return historicCaseInstanceApi.get(caseInstanceId); // fallback to history
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.
Related errors
- Cannot find case instance for id ${caseInstanceId}
- Cannot find case instance with id
- case instance doesn't exist
- case instance doesn't exist
- Cannot find case instance with id
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/498e6e781872e090.
Report an issue: GitHub.