{"record":{"id":"64d3036ab2637818","repo":"flowable/flowable-engine","slug":"variablenames-is-null-or-empty","errorCode":null,"errorMessage":"variableNames is null or empty","messagePattern":"variableNames is null or empty","errorType":"exception","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/HistoricCaseInstanceQueryImpl.java","lineNumber":1046,"sourceCode":"    public String deleteInParallelUsingBatch(int batchSize, String batchName) {\n        return commandExecutor.execute(new DeleteHistoricCaseInstancesUsingBatchesCmd(this, batchSize, batchName, false));\n    }\n\n    @Override\n    public String deleteSequentiallyUsingBatch(int batchSize, String batchName) {\n        return commandExecutor.execute(new DeleteHistoricCaseInstancesUsingBatchesCmd(this, batchSize, batchName, true));\n    }\n\n    @Override\n    public HistoricCaseInstanceQuery includeCaseVariables() {\n        this.includeCaseVariables = true;\n        return this;\n    }\n\n    @Override\n    public HistoricCaseInstanceQuery 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 HistoricCaseInstanceQuery activePlanItemDefinitionId(String planItemDefinitionId) {\n        if (planItemDefinitionId == null) {\n            throw new FlowableIllegalArgumentException(\"planItemDefinitionId is null\");\n        }\n        if (inOrStatement) {\n            this.currentOrQueryObject.activePlanItemDefinitionId = planItemDefinitionId;\n        } else {\n            this.activePlanItemDefinitionId = planItemDefinitionId;\n        }\n        return this;\n    }","sourceCodeStart":1028,"sourceCodeEnd":1064,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/HistoricCaseInstanceQueryImpl.java#L1028-L1064","documentation":"HistoricCaseInstanceQueryImpl.includeCaseVariables(Collection<String>) throws FlowableIllegalArgumentException when the passed collection of variable names is null or empty. The query API requires an explicit, non-empty list of variable names to include in the result, because 'include variables' without a list is meaningless and would produce an invalid query.","triggerScenarios":"Calling includeCaseVariables(null) or includeCaseVariables(Collections.emptyList()) on a HistoricCaseInstanceQuery (or via the CMMN runtime/history service fluent query API) before executing the query.","commonSituations":"Building the variable-name list dynamically from user input or config where the collection ends up null/empty; upgrading Flowable versions where includeCaseVariables() previously called with no args was separated from the collection overload; copying code from case-variable queries and forgetting to populate the list.","solutions":["Ensure the collection passed to includeCaseVariables is non-null and contains at least one variable name before calling it.","If you want ALL case variables included, call the no-arg includeCaseVariables() instead of the collection overload.","Skip calling includeCaseVariables(collection) when the list is empty, and execute the query without variable inclusion.","Add a guard that logs/normalizes empty lists before constructing the query."],"exampleFix":"// before\nquery.includeCaseVariables(variableNames); // variableNames may be null/empty\n// after\nif (variableNames != null && !variableNames.isEmpty()) {\n    query.includeCaseVariables(variableNames);\n}","handlingStrategy":"validation","validationCode":"if (variableNames == null || variableNames.isEmpty()) {\n    throw new IllegalArgumentException(\"variableNames must be non-empty\");\n}\nquery.includeCaseVariables(variableNames);","typeGuard":"boolean isValidVariableNames(Collection<String> c) {\n    return c != null && !c.isEmpty();\n}","tryCatchPattern":"try {\n    query.includeCaseVariables(variableNames);\n} catch (FlowableIllegalArgumentException e) {\n    if (\"variableNames is null or empty\".equals(e.getMessage())) {\n        // fall back to query without included variables or rethrow with context\n    } else {\n        throw e;\n    }\n}","preventionTips":["Null/empty-check collections before adding variable-inclusion filters","Use the no-arg includeCaseVariables() when all variables are wanted","Never let config-driven lists stay null; default to an empty collection and branch","Validate inputs at the API/service boundary before building queries"],"tags":["java","flowable","cmmn","query","null-argument"],"backgroundTag":"null-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"}