{"record":{"id":"f46d1e759c9938fe","repo":"flowable/flowable-engine","slug":"plan-item-instance-planiteminstanceid-doesn-t-e-f46d1e","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/HasPlanItemInstanceVariableCmd.java","lineNumber":48,"sourceCode":"\n    public HasPlanItemInstanceVariableCmd(String caseInstanceId, String variableName) {\n        this.planItemInstanceId = caseInstanceId;\n        this.variableName = variableName;\n    }\n\n    @Override\n    public Boolean execute(CommandContext commandContext) {\n        if (planItemInstanceId == null) {\n            throw new FlowableIllegalArgumentException(\"planItemInstanceId is null\");\n        }\n        if (variableName == null) {\n            throw new FlowableIllegalArgumentException(\"variableName 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        return planItemInstance.hasVariableLocal(variableName);\n    }\n}\n","sourceCodeStart":30,"sourceCodeEnd":53,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/HasPlanItemInstanceVariableCmd.java#L30-L53","documentation":"HasPlanItemInstanceVariableCmd.execute throws FlowableObjectNotFoundException when the given planItemInstanceId does not match any plan item instance in the runtime tables. The ids were valid non-null values, but findById returned null, so the engine reports the plan item instance as nonexistent rather than returning false for the variable check.","triggerScenarios":"Calling hasPlanItemVariable with an id of a plan item that already completed/terminated, a malformed id, or an id from a different case/engine instance.","commonSituations":"Checking variables after the stage/plan item moved to a terminal state, stale ids cached in application state, tests with hard-coded ids, pointing at a different database environment.","solutions":["Look up the plan item first via a PlanItemInstanceQuery and handle absence","If the plan item may have completed, query cmmnHistoryService plan item instance data instead","Validate the id source and database/schema targeting"],"exampleFix":"// before\nboolean has = cmmnRuntimeService.hasPlanItemVariable(piId, \"flag\");\n// after\nPlanItemInstance pii = cmmnRuntimeService.createPlanItemInstanceQuery()\n    .planItemInstanceId(piId).singleResult();\nboolean has = pii != null && cmmnRuntimeService.hasPlanItemVariable(piId, \"flag\");","handlingStrategy":"try-catch","validationCode":"PlanItemInstance pii = cmmnRuntimeService.createPlanItemInstanceQuery()\n    .planItemInstanceId(planItemInstanceId).singleResult();\nif (pii == null) {\n    // plan item absent; use history if needed\n}","typeGuard":"boolean planItemExists(CmmnRuntimeService rs, String id) {\n    return id != null && rs.createPlanItemInstanceQuery().planItemInstanceId(id).singleResult() != null;\n}","tryCatchPattern":"try {\n    return cmmnRuntimeService.hasPlanItemVariable(piId, variableName);\n} catch (FlowableObjectNotFoundException e) {\n    log.warn(\"Plan item instance {} not found\", piId);\n    return false;\n}","preventionTips":["Don't cache plan item ids across state transitions; re-query","Use history service for terminated/completed plan items","Validate ids against the correct engine/database environment"],"tags":["flowable","cmmn","not-found","plan-item"],"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-14T11:17:12.474Z"}