{"record":{"id":"59667694af3c8883","repo":"flowable/flowable-engine","slug":"could-not-find-a-plan-item-instance","errorCode":null,"errorMessage":"Could not find a plan item instance","messagePattern":"Could not find a plan item 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":98,"sourceCode":"        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);\n    }\n\n    protected RestVariable getVariableFromRequestWithoutAccessCheck(String instanceId, String variableName, int variableType, boolean includeBinary) {\n        Object value = null;\n\n        if (variableType == CmmnRestResponseFactory.VARIABLE_PLAN_ITEM) {\n            value = runtimeService.getLocalVariable(instanceId, variableName);\n        } else if (variableType == CmmnRestResponseFactory.VARIABLE_CASE) {\n            value = runtimeService.getVariable(instanceId, variableName);\n        } else {\n            throw new FlowableIllegalArgumentException(\"Unknown variable type \" + variableType);\n        }","sourceCodeStart":80,"sourceCodeEnd":116,"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#L80-L116","documentation":"The PlanItemInstance overload of getVariableFromRequest throws FlowableObjectNotFoundException when given a null planItemInstance, indicating the plan item instance could not be resolved before reading its variables.","triggerScenarios":"Calling the plan-item variable REST endpoint where getPlanItemInstanceFromRequest returned null (unknown planItemInstanceId) and the null instance is then passed into getVariableFromRequest(PlanItemInstance, ...).","commonSituations":"Completed/terminated plan items no longer present in runtime data; wrong plan-item-instance id; ids from a different engine database.","solutions":["Fetch a valid plan item instance id via the plan-item-instance query endpoints first","Use case-level variable endpoints for completed plan items (history)","Validate the id before calling the variable endpoint"],"exampleFix":"// before\nrestVariable = getVariableFromRequest(null, variableName, false);\n// after\nPlanItemInstance pii = resolvePlanItemInstance(id); // must be non-null\nrestVariable = getVariableFromRequest(pii, variableName, false);","handlingStrategy":"try-catch","validationCode":"const res = await fetch(`/cmmn-runtime/plan-item-instances/${planItemInstanceId}`);\nif (!res.ok) throw new Error('Plan item instance not found: ' + planItemInstanceId);","typeGuard":"if (planItemInstance == null) { /* handle not-found upstream */ }","tryCatchPattern":"try { ... } catch (e) {\n  if (e instanceof FlowableObjectNotFoundException) { /* re-resolve plan item or use history */ }\n}","preventionTips":["Confirm plan item still exists at runtime before variable access","Use plan-item-instance query endpoints to validate ids","Handle completed plan items via history variable queries"],"tags":["rest-api","plan-item-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-14T05:17:10.506Z"}