{"record":{"id":"3067c6890aee28ab","repo":"flowable/flowable-engine","slug":"provided-batch-id-is-null","errorCode":null,"errorMessage":"Provided batch id is null","messagePattern":"Provided batch id is null","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-batch-service/src/main/java/org/flowable/batch/service/impl/BatchQueryImpl.java","lineNumber":68,"sourceCode":"    protected boolean withoutTenantId;\n\n    public BatchQueryImpl() {\n    }\n\n    public BatchQueryImpl(CommandContext commandContext, BatchServiceConfiguration batchServiceConfiguration) {\n        super(commandContext);\n        this.batchServiceConfiguration = batchServiceConfiguration;\n    }\n\n    public BatchQueryImpl(CommandExecutor commandExecutor, BatchServiceConfiguration batchServiceConfiguration) {\n        super(commandExecutor);\n        this.batchServiceConfiguration = batchServiceConfiguration;\n    }\n\n    @Override\n    public BatchQuery batchId(String batchId) {\n        if (batchId == null) {\n            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\");","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-batch-service/src/main/java/org/flowable/batch/service/impl/BatchQueryImpl.java#L50-L86","documentation":"BatchQueryImpl.batchId() throws FlowableIllegalArgumentException with message 'Provided batch id is null' when the id argument is null. The batch query validates each filter at setter time so that queries with missing mandatory identifiers fail immediately rather than returning unintended full-table results.","triggerScenarios":"Calling batchService.createBatchQuery().batchId(null), or passing a batch id read from a message/DTO that was not populated.","commonSituations":"Handlers of batch completion events that only carry a batch reference; deserialization of a payload where the id field was absent.","solutions":["Pass the actual batch id string (e.g. from Batch.getId() or the event payload)","Check the id for null before building the query, and fail early with a clearer application-level error","If the id is genuinely absent, look up the batch by searchKey or batchType instead"],"exampleFix":"// before\nBatch batch = batchService.createBatchQuery().batchId(msg.getBatchId()).singleResult();\n// after\nif (msg.getBatchId() == null) {\n    throw new IllegalStateException(\"Message does not carry a batch id\");\n}\nBatch batch = batchService.createBatchQuery().batchId(msg.getBatchId()).singleResult();","handlingStrategy":"validation","validationCode":"if (batchId == null || batchId.isEmpty()) {\n    throw new IllegalArgumentException(\"batchId is required for BatchQuery.batchId()\");\n}\nBatch batch = batchService.createBatchQuery().batchId(batchId).singleResult();","typeGuard":"boolean hasBatchId(String id) { return id != null && !id.isEmpty(); }","tryCatchPattern":"try {\n    batch = batchService.createBatchQuery().batchId(batchId).singleResult();\n} catch (FlowableIllegalArgumentException e) {\n    throw new IllegalArgumentException(\"Cannot look up batch: id missing in payload\", e);\n}","preventionTips":["Fail at payload-deserialization time when the id field is absent","Use singleResult() only after the id is confirmed non-null","Log the raw payload when the id is missing to aid debugging"],"tags":["java","flowable","null-check","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"}