{"record":{"id":"dfe26533a3839ecc","repo":"flowable/flowable-engine","slug":"batchid-is-null","errorCode":null,"errorMessage":"batchId is null","messagePattern":"batchId 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":76,"sourceCode":"\n    @Override\n    public List<BatchPart> executeList(CommandContext commandContext) {\n        return batchServiceConfiguration.getBatchPartEntityManager().findBatchPartsByQueryCriteria(this);\n    }\n\n    @Override\n    public BatchPartQuery id(String id) {\n        if (id == null) {\n            throw new FlowableIllegalArgumentException(\"id is null\");\n        }\n        this.id = id;\n        return this;\n    }\n\n    @Override\n    public BatchPartQuery batchId(String batchId) {\n        if (batchId == null) {\n            throw new FlowableIllegalArgumentException(\"batchId is null\");\n        }\n        this.batchId = batchId;\n        return this;\n    }\n\n    @Override\n    public BatchPartQuery type(String type) {\n        if (type == null) {\n            throw new FlowableIllegalArgumentException(\"type is null\");\n        }\n        this.type = type;\n        return this;\n    }\n\n    @Override\n    public BatchPartQuery searchKey(String searchKey) {\n        if (searchKey == null) {\n            throw new FlowableIllegalArgumentException(\"searchKey is null\");","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-batch-service/src/main/java/org/flowable/batch/service/impl/BatchPartQueryImpl.java#L58-L94","documentation":"BatchPartQueryImpl.batchId(String) filters batch parts by their parent batch. Passing null throws FlowableIllegalArgumentException because a null filter is ambiguous — the library refuses to silently ignore it or match nothing. It is thrown at the batchId(...) call site, not at query execution.","triggerScenarios":"Calling BatchPartQuery.batchId(null), usually when the batch id originates from a nullable variable, an optional lookup of the parent batch, or a request parameter.","commonSituations":"Listing parts of a batch whose id lookup failed (singleResult() on empty query returned null); controllers forwarding missing query params; code that assumed the batch always exists.","solutions":["Null-check the batchId before calling batchId(...); if absent, either abort or run the query without the filter as appropriate.","Resolve the parent Batch first (createBatchQuery().batchId(id).singleResult()) and check it is non-null before querying its parts.","Validate that the batch-creation path actually returned an id."],"exampleFix":"// before\nList<BatchPart> parts = batchService.createBatchPartQuery()\n    .batchId(parentBatchId).list();\n// after\nif (parentBatchId != null) {\n    List<BatchPart> parts = batchService.createBatchPartQuery()\n        .batchId(parentBatchId).list();\n}","handlingStrategy":"validation","validationCode":"if (batchId != null) {\n    parts = batchService.createBatchPartQuery().batchId(batchId).list();\n} else {\n    throw new IllegalArgumentException(\"batchId is required\");\n}","typeGuard":"boolean hasBatchId(String batchId) {\n    return batchId != null && !batchId.isEmpty();\n}","tryCatchPattern":"try {\n    List<BatchPart> parts = query.batchId(batchId).list();\n} catch (org.flowable.common.engine.api.FlowableIllegalArgumentException e) {\n    throw new IllegalArgumentException(\"batchId must not be null when filtering batch parts\", e);\n}","preventionTips":["Confirm the parent batch lookup succeeded (non-null) before querying its parts.","Centralize batch-part queries in a helper that validates batchId once."],"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-14T11:17:12.474Z"}