{"record":{"id":"4649b8e718ef6438","repo":"flowable/flowable-engine","slug":"variablename-is-null-4649b8","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/GetCaseVariableInstanceCmd.java","lineNumber":45,"sourceCode":"public class GetCaseVariableInstanceCmd implements Command<VariableInstance>, Serializable {\n\n    private static final long serialVersionUID = 1L;\n    \n    protected String caseInstanceId;\n    protected String variableName;\n\n    public GetCaseVariableInstanceCmd(String caseInstanceId, String variableName) {\n        this.caseInstanceId = caseInstanceId;\n        this.variableName = variableName;\n    }\n\n    @Override\n    public VariableInstance execute(CommandContext commandContext) {\n        if (caseInstanceId == null) {\n            throw new FlowableIllegalArgumentException(\"caseInstanceId is null\");\n        }\n        if (variableName == null) {\n            throw new FlowableIllegalArgumentException(\"variableName is null\");\n        }\n\n        CmmnEngineConfiguration cmmnEngineConfiguration = CommandContextUtil.getCmmnEngineConfiguration(commandContext);\n        CaseInstanceEntity caseInstance = cmmnEngineConfiguration.getCaseInstanceEntityManager().findById(caseInstanceId);\n\n        if (caseInstance == null) {\n            throw new FlowableObjectNotFoundException(\"case instance \" + caseInstanceId + \" doesn't exist\", CaseInstance.class);\n        }\n\n        return caseInstance.getVariableInstance(variableName, false);\n    }\n}\n","sourceCodeStart":27,"sourceCodeEnd":58,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/GetCaseVariableInstanceCmd.java#L27-L58","documentation":"Flowable's GetCaseVariableInstanceCmd validates its inputs before querying the case instance entity manager. When the variableName passed to the command is null, it aborts immediately with FlowableIllegalArgumentException. This indicates a caller-side bug: the API was invoked without a variable name, which can never resolve to a variable instance.","triggerScenarios":"Calling RuntimeService/CaseService.getCaseVariableInstance (or TaskService equivalent) with a null variable name argument, e.g. cmmnRuntimeService.getVariableInstance(caseInstanceId, null).","commonSituations":"Variable name pulled from a Map key, config property, or database value that is null; refactored code where a constant was replaced by a nullable parameter; dynamic variable lookups where the name is built at runtime.","solutions":["Pass a non-null variableName string to the getCaseVariableInstance call","Check where the variable name originates (Map key, request parameter, config) and fix the null source","Add a null/empty check on the variable name before invoking the API"],"exampleFix":"// before\ncaseService.getVariableInstance(caseInstanceId, variableName);\n// after\nif (variableName != null && !variableName.isEmpty()) {\n    caseService.getVariableInstance(caseInstanceId, variableName);\n}","handlingStrategy":"validation","validationCode":"if (variableName == null || variableName.isEmpty()) { throw new IllegalArgumentException(\"variableName is required\"); }","typeGuard":"boolean hasVariableName = (name instanceof String) && !((String) name).isEmpty();","tryCatchPattern":"try { caseService.getVariableInstance(caseInstanceId, variableName); } catch (FlowableIllegalArgumentException e) { log.error(\"Bad argument: {}\", e.getMessage()); throw e; }","preventionTips":["Never build variable names from nullable values without a guard","Prefer constants or enums for well-known variable names","Validate API inputs at the boundary layer"],"tags":["java","flowable","null-check","argument-validation"],"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"}