{"record":{"id":"61ad0a4f7a4e47a2","repo":"flowable/flowable-engine","slug":"could-not-find-an-plan-item-instance-with-id-id","errorCode":null,"errorMessage":"Could not find an plan item instance with id '${id}'.","messagePattern":"Could not find an 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/planitem/PlanItemInstanceBaseResource.java","lineNumber":224,"sourceCode":"                    if (isCase) {\n                        planItemInstanceQuery.caseVariableValueNotEqualsIgnoreCase(variable.getName(), (String) actualValue);\n                    } else {\n                        planItemInstanceQuery.variableValueNotEqualsIgnoreCase(variable.getName(), (String) actualValue);\n                    }\n                } else {\n                    throw new FlowableIllegalArgumentException(\"Only string variable values are supported when ignoring casing, but was: \" + actualValue.getClass().getName());\n                }\n                break;\n            default:\n                throw new FlowableIllegalArgumentException(\"Unsupported variable query operation: \" + variable.getVariableOperation());\n            }\n        }\n    }\n\n    protected PlanItemInstance getPlanItemInstanceFromRequest(String planItemInstanceId) {\n        PlanItemInstance planItemInstance = runtimeService.createPlanItemInstanceQuery().planItemInstanceId(planItemInstanceId).includeEnded().singleResult();\n        if (planItemInstance == null) {\n            throw new FlowableObjectNotFoundException(\"Could not find an plan item instance with id '\" + planItemInstanceId + \"'.\", PlanItemInstance.class);\n        }\n        \n        if (restApiInterceptor != null) {\n            restApiInterceptor.accessPlanItemInstanceInfoById(planItemInstance);\n        }\n        \n        return planItemInstance;\n    }\n\n    protected Map<String, Object> getVariablesToSet(List<RestVariable> restVariables) {\n        Map<String, Object> variablesToSet = new HashMap<>();\n        for (RestVariable var : restVariables) {\n            if (var.getName() == null) {\n                throw new FlowableIllegalArgumentException(\"Variable name is required\");\n            }\n\n            Object actualVariableValue = restResponseFactory.getVariableValue(var);\n","sourceCodeStart":206,"sourceCodeEnd":242,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-rest/src/main/java/org/flowable/cmmn/rest/service/api/runtime/planitem/PlanItemInstanceBaseResource.java#L206-L242","documentation":"getPlanItemInstanceFromRequest queries the CMMN runtime for a plan item instance by id (including ended instances) and throws FlowableObjectNotFoundException when no match exists. The id is therefore not a live (or previously active) plan item instance in this engine, or the instance was removed/completed and purged.","triggerScenarios":"GET .../cmmn-runtime/plan-item-instances/{planItemInstanceId}, or POST actions (complete/enable/disable/start) on a plan item instance id that does not exist in the runtime database.","commonSituations":"Stale ids cached on the client after the case instance finished; wrong tenant/datasource; referencing a task/execution id instead of a plan item instance id; database cleaned or restarted between calls.","solutions":["Verify the planItemInstanceId exists via the CMMN engine or case query before calling.","Re-query the case instance to obtain fresh plan item instance ids when a case has progressed.","Check tenant/database configuration so you query the engine that actually owns the id.","Catch FlowableObjectNotFoundException (HTTP 404) and treat the resource as gone, prompting a refresh of ids."],"exampleFix":"// before\nclient.post(\"/cmmn-runtime/plan-item-instances/\" + staleId + \"/action\", body);\n// after\nPlanItemInstance p = freshCaseQuery().planItemInstanceId(id).singleResult();\nif (p != null) client.post(\"/cmmn-runtime/plan-item-instances/\" + id + \"/action\", body);","handlingStrategy":"try-catch","validationCode":"const exists = await fetch(`/cmmn-query/plan-item-instances/${id}`).then(r => r.ok);","typeGuard":null,"tryCatchPattern":"try { await getPlanItemInstance(id); } catch (e) { if (e.status === 404) { refreshCasePlanItemIds(); return null; } throw e; }","preventionTips":["Re-fetch plan item ids after any case progression action","Never cache plan item instance ids across case completion","Confirm id type: plan item instance ids differ from task/execution ids"],"tags":["rest-api","not-found","plan-item-instance"],"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-18T11:17:12.947Z"}