{"record":{"id":"e3f42a0c028fcce1","repo":"flowable/flowable-engine","slug":"batchsearchkey-is-null","errorCode":null,"errorMessage":"batchSearchKey is null","messagePattern":"batchSearchKey is null","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-batch-service/src/main/java/org/flowable/batch/service/impl/BatchPartQueryImpl.java","lineNumber":121,"sourceCode":"            throw new FlowableIllegalArgumentException(\"searchKey2 is null\");\n        }\n        this.searchKey2 = searchKey2;\n        return this;\n    }\n\n    @Override\n    public BatchPartQuery batchType(String batchType) {\n        if (batchType == null) {\n            throw new FlowableIllegalArgumentException(\"batchType is null\");\n        }\n        this.batchType = batchType;\n        return this;\n    }\n\n    @Override\n    public BatchPartQuery batchSearchKey(String searchKey) {\n        if (searchKey == null) {\n            throw new FlowableIllegalArgumentException(\"batchSearchKey is null\");\n        }\n        this.batchSearchKey = searchKey;\n        return this;\n    }\n\n    @Override\n    public BatchPartQuery batchSearchKey2(String searchKey2) {\n        if (searchKey2 == null) {\n            throw new FlowableIllegalArgumentException(\"batchSearchKey2 is null\");\n        }\n        this.batchSearchKey2 = searchKey2;\n        return this;\n    }\n\n    @Override\n    public BatchPartQuery status(String status) {\n        if (status == null) {\n            throw new FlowableIllegalArgumentException(\"status is null\");","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-batch-service/src/main/java/org/flowable/batch/service/impl/BatchPartQueryImpl.java#L103-L139","documentation":"BatchPartQueryImpl.batchSearchKey(String) filters batch parts by the parent batch's search key. Passing null throws FlowableIllegalArgumentException at the call site, since null filters are rejected by the query API. Note the parameter is named searchKey locally but validates against the batchSearchKey message.","triggerScenarios":"Calling BatchPartQuery.batchSearchKey(null), typically with a search key sourced from user input, configuration, or a lookup that returned null.","commonSituations":"Empty search fields in UIs; batches created without a batch-level searchKey then queried by it; null propagation from a resolver method.","solutions":["Null-check the search key before applying the batchSearchKey filter.","Skip the filter when the value is absent (conditional query building).","Ensure batches that will be queried this way are created with a non-null searchKey."],"exampleFix":"// before\nBatchPartQuery q = batchService.createBatchPartQuery().batchSearchKey(key);\n// after\nBatchPartQuery q = batchService.createBatchPartQuery();\nif (key != null) {\n    q.batchSearchKey(key);\n}","handlingStrategy":"validation","validationCode":"BatchPartQuery query = batchService.createBatchPartQuery();\nif (batchSearchKey != null) {\n    query.batchSearchKey(batchSearchKey);\n}\nList<BatchPart> parts = query.list();","typeGuard":"boolean hasBatchSearchKey(String k) {\n    return k != null && !k.isEmpty();\n}","tryCatchPattern":"try {\n    List<BatchPart> parts = query.batchSearchKey(key).list();\n} catch (org.flowable.common.engine.api.FlowableIllegalArgumentException e) {\n    throw new IllegalArgumentException(\"batchSearchKey must not be null when filtering batch parts\", e);\n}","preventionTips":["Validate batch-level search keys at creation time so queries downstream always have values.","Guard optional filters before applying them to the query builder."],"tags":["flowable","batch","query","null-check"],"backgroundTag":"null-argument","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-18T11:17:12.947Z"}