{"record":{"id":"ae12bbd2794cfbac","repo":"flowable/flowable-engine","slug":"variablename-is-null-ae12bb","errorCode":null,"errorMessage":"variableName is null","messagePattern":"variableName 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":44,"sourceCode":"public 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":26,"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#L26-L56","documentation":"GetPlanItemVariableInstanceCmd also validates variableName and throws FlowableIllegalArgumentException when it is null. The plan item id check passes but the required variable name is missing, so the command aborts before loading the plan item. Variable names are mandatory keys into the instance's local variable scope.","triggerScenarios":"Calling getPlanItemVariableInstance(planItemInstanceId, variableName) with a null name — commonly from dynamic variable name expressions evaluating to null, or config-driven lookups with missing keys.","commonSituations":"Expression/EL evaluation returning null for the variable name; YAML/JSON config entries where the variable key was omitted; reflection-based generic variable access passing null for optional names.","solutions":["Pass a concrete non-null variable name string.","Validate/trim configured variable names at load time and fail early with the config key in the message.","If the name is dynamic, guard against null evaluation results before the call.","For optional variables, use the all-variables API and check map membership instead."],"exampleFix":"// before\nVariableInstance vi = cmmnRuntimeService.getPlanItemVariableInstance(planItemId, varName); // varName may be null\n// after\nif (varName == null || varName.isEmpty()) { return null; }\nVariableInstance vi = cmmnRuntimeService.getPlanItemVariableInstance(planItemId, varName);","handlingStrategy":"validation","validationCode":"Objects.requireNonNull(variableName, \"variableName is required\");\nif (variableName.trim().isEmpty()) throw new IllegalArgumentException(\"variableName must not be blank\");","typeGuard":"boolean hasVariableName(String name) { return name != null && !name.trim().isEmpty(); }","tryCatchPattern":"try {\n    vi = cmmnRuntimeService.getPlanItemVariableInstance(planItemInstanceId, variableName);\n} catch (FlowableIllegalArgumentException e) {\n    log.warn(\"Missing variable name for plan item {}\", planItemInstanceId);\n    vi = null;\n}","preventionTips":["Validate configured variable names at startup","Guard EL/script expressions that may evaluate to null","Use getPlanItemVariableInstances + map lookup for optional variables","Never pass null names to single-variable APIs"],"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"}