{"record":{"id":"3334b7795e9d4470","repo":"flowable/flowable-engine","slug":"planiteminstanceid-is-null-3334b7","errorCode":null,"errorMessage":"planItemInstanceId is null","messagePattern":"planItemInstanceId is null","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/HasPlanItemInstanceVariableCmd.java","lineNumber":39,"sourceCode":"import org.flowable.common.engine.impl.interceptor.CommandContext;\n\n/**\n * @author Christopher Welsch\n */\npublic class HasPlanItemInstanceVariableCmd implements Command<Boolean> {\n\n    protected String planItemInstanceId;\n    protected String variableName;\n\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":21,"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#L21-L53","documentation":"HasPlanItemInstanceVariableCmd.execute throws FlowableIllegalArgumentException when planItemInstanceId is null. The command requires both a plan item instance id and a variable name; without the id it cannot locate the plan item instance, so it fails fast before any database access.","triggerScenarios":"Calling cmmnRuntimeService.hasPlanItemVariable(null, variableName) or the local variant, or constructing the command directly with a null id.","commonSituations":"Plan item id obtained from a listener/stage context that was null (e.g. evaluated outside an active plan item), an uninitialized variable in custom delegation code, or a lookup that returned no result upstream.","solutions":["Ensure the plan item instance id is captured from a valid PlanItemInstance before calling","Guard the call with a null check on the id","If deriving the id from a query, handle the null singleResult() case first"],"exampleFix":"// before\nboolean has = cmmnRuntimeService.hasPlanItemVariable(planItemInstanceId, \"flag\");\n// after\nif (planItemInstanceId != null) {\n    boolean has = cmmnRuntimeService.hasPlanItemVariable(planItemInstanceId, \"flag\");\n}","handlingStrategy":"validation","validationCode":"if (planItemInstanceId == null) {\n    throw new IllegalArgumentException(\"planItemInstanceId is required\");\n}","typeGuard":"boolean hasPlanItemInstanceId(String id) {\n    return id != null && !id.isEmpty();\n}","tryCatchPattern":"try {\n    return cmmnRuntimeService.hasPlanItemVariable(planItemInstanceId, variableName);\n} catch (FlowableIllegalArgumentException e) {\n    log.warn(\"Invalid hasPlanItemVariable args: {}\", e.getMessage());\n    return false;\n}","preventionTips":["Capture plan item ids only from live PlanItemInstance objects inside listeners","Null-check ids from upstream lookups","Use a facade that validates arguments before delegating to the runtime service"],"tags":["flowable","cmmn","null-argument","plan-item"],"backgroundTag":"null-argument","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"}