{"record":{"id":"dbd5291fff595524","repo":"flowable/flowable-engine","slug":"planiteminstanceid-is-null-dbd529","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/GetPlanItemVariableInstanceCmd.java","lineNumber":41,"sourceCode":"import org.flowable.common.engine.impl.interceptor.CommandContext;\nimport org.flowable.variable.api.persistence.entity.VariableInstance;\n\npublic class GetPlanItemVariableInstanceCmd implements Command<VariableInstance>, Serializable {\n\n    private static final long serialVersionUID = 1L;\n    \n    protected String planItemInstanceId;\n    protected String variableName;\n\n    public GetPlanItemVariableInstanceCmd(String planItemInstanceId, String variableName) {\n        this.planItemInstanceId = planItemInstanceId;\n        this.variableName = variableName;\n    }\n\n    @Override\n    public VariableInstance 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\n        return planItemInstance.getVariableInstance(variableName, false);\n    }\n}\n","sourceCodeStart":23,"sourceCodeEnd":56,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/GetPlanItemVariableInstanceCmd.java#L23-L56","documentation":"GetPlanItemVariableInstanceCmd first validates planItemInstanceId and throws FlowableIllegalArgumentException if it is null. This is an argument-validation error thrown in execute() before any entity lookup. The command is used by plan-item variable APIs returning a VariableInstance object.","triggerScenarios":"Calling getPlanItemVariableInstance(planItemInstanceId, variableName) style APIs with null id — e.g. variable resolvers invoked for plan items that never got instantiated, or delegation code dropping the id.","commonSituations":"Custom variable listeners/resolvers called with partial context; templated API calls where the id placeholder was empty; misordered arguments passing variableName first.","solutions":["Supply a resolved, non-null plan item instance id to the API.","Add requireNonNull assertions in caller code before the engine call.","Ensure listeners/processors skip plan items without ids rather than calling the API.","Check argument order and payload mapping for the call."],"exampleFix":"// before\nVariableInstance vi = cmmnRuntimeService.getPlanItemVariableInstance(planItemId, varName);\n// after\nif (planItemId == null) { throw new IllegalArgumentException(\"planItemId required\"); }\nVariableInstance vi = cmmnRuntimeService.getPlanItemVariableInstance(planItemId, varName);","handlingStrategy":"validation","validationCode":"Objects.requireNonNull(planItemInstanceId, \"planItemInstanceId is required\");","typeGuard":"boolean hasPlanItemId(String id) { return id != null && !id.trim().isEmpty(); }","tryCatchPattern":"try {\n    vi = cmmnRuntimeService.getPlanItemVariableInstance(planItemInstanceId, variableName);\n} catch (FlowableIllegalArgumentException e) {\n    log.warn(\"Invalid plan item variable lookup arguments\");\n    vi = null;\n}","preventionTips":["Check argument order (id first, name second)","Guard dynamic/expression-derived ids against null","Require ids in listener/processor context","Assert preconditions before engine calls"],"tags":["flowable","cmmn","null-argument","variables"],"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"}