{"record":{"id":"6fe434406eeca928","repo":"flowable/flowable-engine","slug":"no-plan-item-instance-found-for-id-planiteminsta","errorCode":null,"errorMessage":"No plan item instance found for id ${planItemInstanceId}","messagePattern":"No plan item instance found for id (.+?)","errorType":"validation","errorClass":"FlowableObjectNotFoundException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/SetLocalVariableAsyncCmd.java","lineNumber":47,"sourceCode":"    public SetLocalVariableAsyncCmd(String planItemInstanceId, String variableName, Object variableValue) {\n        this.planItemInstanceId = planItemInstanceId;\n        this.variableName = variableName;\n        this.variableValue = variableValue;\n    }\n    \n    @Override\n    public Void execute(CommandContext commandContext) {\n        if (planItemInstanceId == null) {\n            throw new FlowableIllegalArgumentException(\"planItemInstanceId is null\");\n        }\n        if (variableName == null) {\n            throw new FlowableIllegalArgumentException(\"variable name is null\");\n        }\n     \n        CmmnEngineConfiguration cmmnEngineConfiguration = CommandContextUtil.getCmmnEngineConfiguration(commandContext);\n        PlanItemInstanceEntity planItemInstanceEntity = cmmnEngineConfiguration.getPlanItemInstanceEntityManager().findById(planItemInstanceId);\n        if (planItemInstanceEntity == null) {\n            throw new FlowableObjectNotFoundException(\"No plan item instance found for id \" + planItemInstanceId, PlanItemInstanceEntity.class);\n        }\n        \n        addVariable(true, planItemInstanceEntity.getCaseInstanceId(), planItemInstanceEntity.getId(), variableName, variableValue, planItemInstanceEntity.getTenantId(), \n                cmmnEngineConfiguration.getVariableServiceConfiguration().getVariableService());\n        createSetAsyncVariablesJob(planItemInstanceEntity, cmmnEngineConfiguration);\n        \n        return null;\n    }\n\n}\n","sourceCodeStart":29,"sourceCodeEnd":58,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/SetLocalVariableAsyncCmd.java#L29-L58","documentation":"Thrown by SetLocalVariableAsyncCmd.execute when the plan item instance id is non-null but no PlanItemInstanceEntity exists for it. Flowable throws FlowableObjectNotFoundException (typed PlanItemInstanceEntity) and neither the variable nor the async job is created.","triggerScenarios":"Calling setLocalVariableAsync with an id for a plan item instance that does not exist or has already been removed.","commonSituations":"Setting a variable on a plan item whose stage already completed/terminated; id captured before a case rollback; race condition where the plan item ended between lookup and variable set; wrong environment database.","solutions":["Re-fetch the plan item instance (planItemInstanceQuery().planItemInstanceId(id)) right before setting the variable","Verify the plan item is still active; completed plan items no longer accept local variables","Check for concurrent case termination in your workflow and handle it","Catch FlowableObjectNotFoundException and fail gracefully with a not-found response"],"exampleFix":"// before\ncmmnRuntimeService.setLocalVariableAsync(planItemInstanceId, variableName, value);\n// after\nPlanItemInstance pii = cmmnRuntimeService.createPlanItemInstanceQuery().planItemInstanceId(planItemInstanceId).singleResult();\nif (pii != null) {\n    cmmnRuntimeService.setLocalVariableAsync(planItemInstanceId, variableName, value);\n} else {\n    logger.warn(\"Plan item instance {} no longer exists\", planItemInstanceId);\n}","handlingStrategy":"try-catch","validationCode":"PlanItemInstance pii = cmmnRuntimeService.createPlanItemInstanceQuery().planItemInstanceId(planItemInstanceId).singleResult();\nif (pii == null) { throw new NotFoundException(\"Plan item instance not found: \" + planItemInstanceId); }","typeGuard":null,"tryCatchPattern":"try {\n    cmmnRuntimeService.setLocalVariableAsync(planItemInstanceId, variableName, value);\n} catch (FlowableObjectNotFoundException e) {\n    logger.warn(\"Plan item instance {} disappeared before variable write\", planItemInstanceId);\n    throw new NotFoundException(e.getMessage(), e);\n}","preventionTips":["Re-verify the plan item is still active immediately before async writes","Design for races: plan items can complete/terminate concurrently","Catch FlowableObjectNotFoundException in job/async handlers to avoid cascading failures","Check environment/datasource consistency across services"],"tags":["flowable","cmmn","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-14T05:17:10.506Z"}