{"record":{"id":"8cfefbd4e3399d1c","repo":"flowable/flowable-engine","slug":"could-not-find-a-plan-item-instance-with-id-pla-8cfefb","errorCode":null,"errorMessage":"Could not find a plan item instance with id '${planItemInstanceId}'.","messagePattern":"Could not find a plan item 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/BaseVariableResource.java","lineNumber":73,"sourceCode":"\n    @Autowired\n    protected ObjectMapper objectMapper;\n\n    \n    @Autowired\n    protected Environment env;\n    \n    protected boolean isSerializableVariableAllowed;\n\n    @Override\n    public void afterPropertiesSet() {\n        isSerializableVariableAllowed = env.getProperty(\"rest.variables.allow.serializable\", Boolean.class, true);\n    }\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        }","sourceCodeStart":55,"sourceCodeEnd":91,"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#L55-L91","documentation":"getPlanItemInstanceFromRequest queries the runtime for a plan item instance by id; when no match is found it throws FlowableObjectNotFoundException. The supplied planItemInstanceId does not reference an existing plan item instance in the CMMN runtime.","triggerScenarios":"Calling plan-item variable endpoints (e.g. GET/PUT/DELETE on plan-item variable resources) with a planItemInstanceId path parameter that is nonexistent, already completed/terminated (moved out of runtime), or malformed.","commonSituations":"Using a case instance id instead of a plan item instance id; plan item completed so it no longer appears in plan item instance runtime data; stale ids saved from a previous session; wrong tenant/database.","solutions":["Verify the planItemInstanceId exists via GET plan-item-instance queries first","Use the correct id type (plan item instance id, not case instance id or plan item definition id)","Check whether the plan item already completed — historical data lives in the history service, not runtime","Confirm you are pointed at the same database/tenant where the case is running"],"exampleFix":"// before\nString id = caseInstance.getId(); // wrong id\n// after\nPlanItemInstance pii = runtimeService.createPlanItemInstanceQuery().planItemInstanceCaseInstanceId(caseInstance.getId()).singleResult();\nString id = pii.getId();","handlingStrategy":"try-catch","validationCode":"const pii = await fetch(`/cmmn-runtime/plan-item-instances/${id}`);\nif (!pii.ok) throw new Error('Plan item instance not found: ' + id);","typeGuard":null,"tryCatchPattern":"try { ... } catch (e) {\n  if (e instanceof FlowableObjectNotFoundException) {\n    // fall back to history query for completed plan items\n  }\n}","preventionTips":["Resolve plan item ids via query endpoints before variable operations","Remember completed plan items leave the runtime (use history)","Don't confuse case instance ids with plan item instance ids"],"tags":["rest-api","plan-item-instance","not-found","cmmn"],"backgroundTag":"resource-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"}