{"record":{"id":"c79c67e0a08a0d3c","repo":"apache/seatunnel","slug":"cannot-build-a-nebulagraph-request-for-an-empty-ba","errorCode":null,"errorMessage":"Cannot build a NebulaGraph request for an empty batch.","messagePattern":"Cannot build a NebulaGraph request for an empty batch\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-nebulagraph/src/main/java/org/apache/seatunnel/connectors/seatunnel/nebulagraph/sink/NebulaGraphStatementBuilder.java","lineNumber":51,"sourceCode":"    private static final Pattern IDENTIFIER = Pattern.compile(\"[A-Za-z_][A-Za-z0-9_]*\");\n\n    private final String quotedTag;\n    private final List<String> propertyNames;\n    private final NebulaGraphWriteMode writeMode;\n\n    NebulaGraphStatementBuilder(\n            String tag, List<String> propertyNames, NebulaGraphWriteMode writeMode) {\n        this.quotedTag = quoteIdentifier(tag);\n        this.propertyNames =\n                propertyNames.stream()\n                        .map(NebulaGraphStatementBuilder::validateIdentifier)\n                        .collect(Collectors.toList());\n        this.writeMode = writeMode;\n    }\n\n    NebulaGraphWriteRequest build(List<NebulaGraphVertex> vertices) {\n        if (vertices.isEmpty()) {\n            throw new IllegalArgumentException(\n                    \"Cannot build a NebulaGraph request for an empty batch.\");\n        }\n        if (writeMode == NebulaGraphWriteMode.INSERT) {\n            return buildInsert(vertices);\n        }\n        return buildUpdate(vertices);\n    }\n\n    private NebulaGraphWriteRequest buildInsert(List<NebulaGraphVertex> vertices) {\n        Map<String, Object> parameters = new LinkedHashMap<>();\n        List<String> values = new ArrayList<>(vertices.size());\n        for (int row = 0; row < vertices.size(); row++) {\n            NebulaGraphVertex vertex = vertices.get(row);\n\n            List<String> propertyParameters = new ArrayList<>(propertyNames.size());\n            for (int field = 0; field < propertyNames.size(); field++) {\n                String parameter = parameterName(row, field);\n                parameters.put(parameter, vertex.getProperties().get(propertyNames.get(field)));","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-nebulagraph/src/main/java/org/apache/seatunnel/connectors/seatunnel/nebulagraph/sink/NebulaGraphStatementBuilder.java#L33-L69","documentation":"NebulaGraphStatementBuilder.build() requires a non-empty list of vertices because it constructs an nGQL INSERT/UPDATE statement from them; an empty list would produce syntactically invalid nGQL, so it throws IllegalArgumentException immediately. This is an internal invariant check on batch construction.","triggerScenarios":"Calling build(List.of()) directly (as in tests) or via request() when the accumulated batch of NebulaGraphVertex is empty — e.g. flush triggered with nothing buffered.","commonSituations":"Empty upstream data leading to a zero-row batch flush; filter transforms removing all rows before the sink; unit tests probing boundary behavior of the statement builder.","solutions":["Skip building/sending the request when the vertex list is empty: only call build() if !vertices.isEmpty()","Check upstream transform logic if batches are unexpectedly empty on flush","If calling the builder from custom code, add a size check before invocation"],"exampleFix":"// before\nNebulaGraphWriteRequest req = builder.build(vertices);\n// after\nif (!vertices.isEmpty()) {\n    NebulaGraphWriteRequest req = builder.build(vertices);\n}","handlingStrategy":"validation","validationCode":"if (vertices == null || vertices.isEmpty()) { return; } // skip build/flush","typeGuard":null,"tryCatchPattern":"try { req = builder.build(vertices); } catch (IllegalArgumentException e) { if (e.getMessage().contains(\"empty batch\")) { req = null; } else { throw e; } }","preventionTips":["Check batch size before building requests","Only flush when the buffer has accumulated rows","Guard upstream filters that may remove all rows"],"tags":["java","nebulagraph","empty-batch"],"backgroundTag":"empty-required-field","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}