{"record":{"id":"d2d1376e2cdbe7ce","repo":"flowable/flowable-engine","slug":"provided-batch-types-must-be-provided-and-not-empt","errorCode":null,"errorMessage":"Provided batch types must be provided and not empty","messagePattern":"Provided batch types must be provided and not empty","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-batch-service/src/main/java/org/flowable/batch/service/impl/BatchQueryImpl.java","lineNumber":86,"sourceCode":"            throw new FlowableIllegalArgumentException(\"Provided batch id is null\");\n        }\n        this.id = batchId;\n        return this;\n    }\n\n    @Override\n    public BatchQuery batchType(String batchType) {\n        if (batchType == null) {\n            throw new FlowableIllegalArgumentException(\"Provided batch type is null\");\n        }\n        this.batchType = batchType;\n        return this;\n    }\n\n    @Override\n    public BatchQuery batchTypes(Collection<String> batchTypes) {\n        if (batchTypes == null || batchTypes.isEmpty()) {\n            throw new FlowableIllegalArgumentException(\"Provided batch types must be provided and not empty\");\n        }\n        this.batchTypes = batchTypes;\n        return this;\n    }\n\n    @Override\n    public BatchQuery searchKey(String searchKey) {\n        if (searchKey == null) {\n            throw new FlowableIllegalArgumentException(\"Provided search key is null\");\n        }\n        this.searchKey = searchKey;\n        return this;\n    }\n    \n    @Override\n    public BatchQuery searchKey2(String searchKey) {\n        if (searchKey == null) {\n            throw new FlowableIllegalArgumentException(\"Provided search key is null\");","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-batch-service/src/main/java/org/flowable/batch/service/impl/BatchQueryImpl.java#L68-L104","documentation":"BatchQueryImpl.batchTypes() throws FlowableIllegalArgumentException when the collection is null OR empty. Unlike single-value setters, an empty list is also rejected because it would translate to a meaningless SQL IN () clause; omit the call entirely to query all types.","triggerScenarios":"Calling createBatchQuery().batchTypes(null) or .batchTypes(Collections.emptyList()), typically when the list is built dynamically from config or user-selected types.","commonSituations":"Filter UIs where no type was selected (empty list) and the list is forwarded unchecked; configuration lists that failed to load.","solutions":["Pass a non-empty collection of batch types","Skip the .batchTypes(...) call when the collection is null or empty (means: no type filter)","Add a size check before forwarding user/config-driven lists"],"exampleFix":"// before\nquery.batchTypes(selectedTypes); // may be null or empty\n// after\nif (selectedTypes != null && !selectedTypes.isEmpty()) {\n    query.batchTypes(selectedTypes);\n}","handlingStrategy":"validation","validationCode":"if (batchTypes == null || batchTypes.isEmpty()) {\n    // no filter requested: do not call batchTypes()\n} else {\n    query.batchTypes(batchTypes);\n}","typeGuard":"boolean isNonEmpty(Collection<String> c) { return c != null && !c.isEmpty(); }","tryCatchPattern":"try {\n    query.batchTypes(batchTypes);\n} catch (FlowableIllegalArgumentException e) {\n    // interpret as 'all types' and continue without the filter\n}","preventionTips":["Normalize null/empty collections to 'no filter' before building queries","Validate user multi-select inputs (require at least one type or treat as all)","Note that unlike single-value setters, empty collections are also rejected here"],"tags":["java","flowable","null-check","empty-collection","query-api"],"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"}