flowable/flowable-engine · error · FlowableObjectNotFoundException

Could not find a case instance

Error message

Could not find a case instance

What it means

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.

Source

Thrown at modules/flowable-cmmn-rest/src/main/java/org/flowable/cmmn/rest/service/api/runtime/caze/BaseVariableResource.java:86

    }

    protected PlanItemInstance getPlanItemInstanceFromRequest(String planItemInstanceId) {
        PlanItemInstance planItemInstance = runtimeService.createPlanItemInstanceQuery().planItemInstanceId(planItemInstanceId).singleResult();
        if (planItemInstance == null) {
            throw new FlowableObjectNotFoundException("Could not find a plan item instance with id '" + planItemInstanceId + "'.");
        }

        if (restApiInterceptor != null) {
            restApiInterceptor.accessPlanItemInstanceInfoById(planItemInstance);
        }

        return planItemInstance;
    }

    public RestVariable getVariableFromRequest(CaseInstance caseInstance, String variableName, boolean includeBinary) {

        if (caseInstance == null) {
            throw new FlowableObjectNotFoundException("Could not find a case instance", CaseInstance.class);
        }

        if (restApiInterceptor != null) {
            restApiInterceptor.accessCaseInstanceVariable(caseInstance, variableName);
        }

        return getVariableFromRequestWithoutAccessCheck(caseInstance.getId(), variableName, CmmnRestResponseFactory.VARIABLE_CASE, includeBinary);
    }

    public RestVariable getVariableFromRequest(PlanItemInstance planItemInstance, String variableName, boolean includeBinary) {
        if (planItemInstance == null) {
            throw new FlowableObjectNotFoundException("Could not find a plan item instance", CaseInstance.class);
        }

        if (restApiInterceptor != null) {
            restApiInterceptor.accessPlanItemInstanceVariable(planItemInstance, variableName);
        }
        return getVariableFromRequestWithoutAccessCheck(planItemInstance.getId(), variableName, CmmnRestResponseFactory.VARIABLE_PLAN_ITEM, includeBinary);

View on GitHub (pinned to d6d39ce1c6)

Solutions

  1. Confirm the case instance is still running via a case-instance query before fetching variables
  2. Use the case history service for completed case instances' variables
  3. Fix the caseInstanceId path parameter

Example fix

// before
restVariable = getVariableFromRequest(null, variableName, false); // lookup failed upstream
// after
if (caseInstance == null) throw notFound; // resolve valid CaseInstance first
restVariable = getVariableFromRequest(caseInstance, variableName, false);
Defensive patterns

Strategy: try-catch

Validate before calling

const ci = await fetch(`/cmmn-runtime/case-instances/${caseId}`);
if (!ci.ok) throw new Error('Case instance not running: ' + caseId);

Type guard

if (caseInstance == null) { /* treat as not-found before calling */ }

Try / catch

try { ... } catch (e) {
  if (e instanceof FlowableObjectNotFoundException) { /* check history for ended case */ }
}

Prevention

When it happens

Trigger: 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).

Common situations: Requesting variables of a case instance that has already ended (moved to history); wrong caseInstanceId path parameter; ids from another database.

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


AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11). Data as JSON: /api/errors/217c7448cfb02a62. Report an issue: GitHub.