{"record":{"id":"7fc9122d8a0ecfdf","repo":"flowable/flowable-engine","slug":"plan-item-instance-planiteminstanceid-doesn-t-e-7fc912","errorCode":null,"errorMessage":"plan item instance ${planItemInstanceId} doesn't exist","messagePattern":"plan item instance (.+?) doesn't exist","errorType":"exception","errorClass":"FlowableObjectNotFoundException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/GetPlanItemVariableInstancesCmd.java","lineNumber":48,"sourceCode":"    \n    protected String planItemInstanceId;\n\n    public GetPlanItemVariableInstancesCmd(String planItemInstanceId) {\n        this.planItemInstanceId = planItemInstanceId;\n    }\n\n    @Override\n    public Map<String, VariableInstance> execute(CommandContext commandContext) {\n\n        // Verify existence of execution\n        if (planItemInstanceId == null) {\n            throw new FlowableIllegalArgumentException(\"planItemInstanceId is null\");\n        }\n\n        PlanItemInstanceEntity planItemInstance = CommandContextUtil.getPlanItemInstanceEntityManager(commandContext).findById(planItemInstanceId);\n\n        if (planItemInstance == null) {\n            throw new FlowableObjectNotFoundException(\"plan item instance \" + planItemInstanceId + \" doesn't exist\", PlanItemInstance.class);\n        }\n\n        return planItemInstance.getVariableInstancesLocal();\n    }\n}\n","sourceCodeStart":30,"sourceCodeEnd":54,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/GetPlanItemVariableInstancesCmd.java#L30-L54","documentation":"GetPlanItemVariableInstancesCmd throws FlowableObjectNotFoundException ('plan item instance <id> doesn't exist') when the PlanItemInstanceEntityManager findById returns null after argument validation succeeds. The caller provided a syntactically valid id, but no such live plan item instance exists in the runtime store.","triggerScenarios":"Reading all local variables of a plan item that has completed, been terminated, or whose parent case finished; stale ids from earlier deployments or prior test data; wrong database/environment; id-type confusion with case or stage ids.","commonSituations":"Aggregation jobs walking old plan item snapshots; UIs holding ids after case completion; concurrent termination while variables were being read; data cleanup jobs removing runtime rows mid-flight.","solutions":["Pre-check existence with createPlanItemInstanceQuery().planItemInstanceId(id).singleResult() and handle null gracefully.","For ended items, retrieve variables from history (cmmnHistoryService historic variable instance queries).","Re-acquire current plan item ids from the running case instance before reading variables.","Ensure all clients operate against the same engine database and schema."],"exampleFix":"// before\nMap<String, VariableInstance> vars = cmmnRuntimeService.getPlanItemVariableInstances(planItemId);\n// after\nPlanItemInstance pii = cmmnRuntimeService.createPlanItemInstanceQuery().planItemInstanceId(planItemId).singleResult();\nMap<String, VariableInstance> vars = (pii != null) ? cmmnRuntimeService.getPlanItemVariableInstances(planItemId) : Collections.emptyMap();","handlingStrategy":"try-catch","validationCode":"PlanItemInstance pii = cmmnRuntimeService.createPlanItemInstanceQuery().planItemInstanceId(planItemInstanceId).singleResult();\nif (pii == null) return Collections.emptyMap();","typeGuard":"boolean planItemInstanceExists(String id) {\n    return cmmnRuntimeService.createPlanItemInstanceQuery().planItemInstanceId(id).count() > 0;\n}","tryCatchPattern":"try {\n    vars = cmmnRuntimeService.getPlanItemVariableInstances(planItemInstanceId);\n} catch (FlowableObjectNotFoundException e) {\n    log.warn(\"Plan item {} no longer exists; using history\", planItemInstanceId);\n    vars = variablesFromHistory(planItemInstanceId);\n}","preventionTips":["Check plan item existence before fetching variables","Use history queries for ended plan items","Avoid caching plan item ids across transactions","Account for concurrent case completion in readers"],"tags":["flowable","cmmn","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"}