apache/seatunnel · error · IllegalArgumentException
Cannot build a NebulaGraph request for an empty batch.
Error message
Cannot build a NebulaGraph request for an empty batch.
What it means
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.
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
Example fix
// before
NebulaGraphWriteRequest req = builder.build(vertices);
// after
if (!vertices.isEmpty()) {
NebulaGraphWriteRequest req = builder.build(vertices);
} Defensive patterns
Strategy: validation
Validate before calling
if (vertices == null || vertices.isEmpty()) { return; } // skip build/flush Try / catch
try { req = builder.build(vertices); } catch (IllegalArgumentException e) { if (e.getMessage().contains("empty batch")) { req = null; } else { throw e; } } Prevention
- Check batch size before building requests
- Only flush when the buffer has accumulated rows
- Guard upstream filters that may remove all rows
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- INVALID_CONFIG
- NebulaGraph sink writer is already closed.
- NebulaGraph sink writer is in a failed state.
- NebulaGraph string vertex IDs must not contain unsupported…
- ACKNOWLEDGE_FAILED
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/c79c67e0a08a0d3c.
Report an issue: GitHub.
Appendix: source
Thrown at seatunnel-connectors-v2/connector-nebulagraph/src/main/java/org/apache/seatunnel/connectors/seatunnel/nebulagraph/sink/NebulaGraphStatementBuilder.java:51
private static final Pattern IDENTIFIER = Pattern.compile("[A-Za-z_][A-Za-z0-9_]*");
private final String quotedTag;
private final List<String> propertyNames;
private final NebulaGraphWriteMode writeMode;
NebulaGraphStatementBuilder(
String tag, List<String> propertyNames, NebulaGraphWriteMode writeMode) {
this.quotedTag = quoteIdentifier(tag);
this.propertyNames =
propertyNames.stream()
.map(NebulaGraphStatementBuilder::validateIdentifier)
.collect(Collectors.toList());
this.writeMode = writeMode;
}
NebulaGraphWriteRequest build(List<NebulaGraphVertex> vertices) {
if (vertices.isEmpty()) {
throw new IllegalArgumentException(
"Cannot build a NebulaGraph request for an empty batch.");
}
if (writeMode == NebulaGraphWriteMode.INSERT) {
return buildInsert(vertices);
}
return buildUpdate(vertices);
}
private NebulaGraphWriteRequest buildInsert(List<NebulaGraphVertex> vertices) {
Map<String, Object> parameters = new LinkedHashMap<>();
List<String> values = new ArrayList<>(vertices.size());
for (int row = 0; row < vertices.size(); row++) {
NebulaGraphVertex vertex = vertices.get(row);
List<String> propertyParameters = new ArrayList<>(propertyNames.size());
for (int field = 0; field < propertyNames.size(); field++) {
String parameter = parameterName(row, field);
parameters.put(parameter, vertex.getProperties().get(propertyNames.get(field)));View on GitHub (pinned to cf67b549a7)