{"record":{"id":"7eeb9e0ca350bdfb","repo":"flowable/flowable-engine","slug":"variablenames-is-null-or-empty-7eeb9e","errorCode":null,"errorMessage":"variableNames is null or empty","messagePattern":"variableNames is null or empty","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/runtime/CaseInstanceQueryImpl.java","lineNumber":1068,"sourceCode":"        return this;\n    }\n\n    @Override\n    public CaseInstanceQueryImpl orderByTenantId() {\n        this.orderProperty = CaseInstanceQueryProperty.TENANT_ID;\n        return this;\n    }\n\n    @Override\n    public CaseInstanceQueryImpl includeCaseVariables() {\n        this.includeCaseVariables = true;\n        return this;\n    }\n\n    @Override\n    public CaseInstanceQuery includeCaseVariables(Collection<String> variableNames) {\n        if (variableNames == null || variableNames.isEmpty()) {\n            throw new FlowableIllegalArgumentException(\"variableNames is null or empty\");\n        }\n        includeCaseVariables();\n        this.variableNamesToInclude = new LinkedHashSet<>(variableNames);\n        return this;\n    }\n\n    @Override\n    public CaseInstanceQuery locale(String locale) {\n        this.locale = locale;\n        return this;\n    }\n\n    @Override\n    public CaseInstanceQuery withLocalizationFallback() {\n        this.withLocalizationFallback = true;\n        return this;\n    }\n","sourceCodeStart":1050,"sourceCodeEnd":1086,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/runtime/CaseInstanceQueryImpl.java#L1050-L1086","documentation":"CaseInstanceQueryImpl.includeCaseVariables(Collection<String>) validates its input before enabling variable inclusion on the query. If the collection is null or empty, the query would be semantically identical to no inclusion, so Flowable throws FlowableIllegalArgumentException to surface the misuse immediately.","triggerScenarios":"Calling cmmnRuntimeService.createCaseInstanceQuery().includeCaseVariables(null) or includeCaseVariables(Collections.emptyList()) / an empty set or list.","commonSituations":"Passing a variable-name list that was built dynamically (e.g., from user selection or config) and turned out empty; passing null because a caller variable was never initialized; refactoring code that previously called includeCaseVariables() (no-arg) and incorrectly switched to the collection variant.","solutions":["Ensure the variable-name collection is populated before calling includeCaseVariables; fall back to includeCaseVariables() (no-arg) when you want all variables","Guard with a null/empty check and skip the call or use the no-arg variant","Fix the upstream source of the collection so it is not null/empty"],"exampleFix":"// before\nquery.includeCaseVariables(variableNames); // NPE/IAE when variableNames is null/empty\n// after\nif (variableNames == null || variableNames.isEmpty()) {\n    query.includeCaseVariables(); // include all variables\n} else {\n    query.includeCaseVariables(variableNames);\n}","handlingStrategy":"validation","validationCode":"if (variableNames == null || variableNames.isEmpty()) { query.includeCaseVariables(); } else { query.includeCaseVariables(variableNames); }","typeGuard":"boolean hasVariables(Collection<String> c) { return c != null && !c.isEmpty(); }","tryCatchPattern":"try { query.includeCaseVariables(variableNames); } catch (FlowableIllegalArgumentException e) { query.includeCaseVariables(); }","preventionTips":["Null/empty-check dynamically built variable name collections before querying","Prefer the no-arg includeCaseVariables() when all variables are wanted","Unit-test query builders with empty collection inputs"],"tags":["flowable","cmmn","query","validation","null-argument"],"backgroundTag":"missing-required-argument","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"}