apache/seatunnel · error · IllegalArgumentException
event must not be empty
Error message
event must not be empty
What it means
LineOutputFormatter.format() requires a non-empty list of LineElement because it reads the first and last elements to build the CollectedRecord boundaries. An empty event has no valid line range, so it is rejected with IllegalArgumentException.
Solutions
- Check event.isEmpty() before invoking the formatter and skip the call
- Fix the assembler so flush() is a no-op when the buffer is empty
- Wrap the call in try-catch for IllegalArgumentException as a defensive last resort
Example fix
// before
CollectedRecord r = lineFormatter.format(event, sourceId);
// after
if (event == null || event.isEmpty()) {
return;
}
CollectedRecord r = lineFormatter.format(event, sourceId); Defensive patterns
Strategy: type-guard
Validate before calling
if (event == null || event.isEmpty()) { return; } Type guard
boolean hasEvent(List<MultilineAssembler.LineElement> e) { return e != null && !e.isEmpty(); } Try / catch
try { lineFormatter.format(event, sourceId); } catch (IllegalArgumentException e) { LOG.warn("Ignoring empty event", e); } Prevention
- Guard against empty lists before any formatter call
- Make assembler flush idempotent on empty buffers
- Unit-test the flush path for empty-buffer behavior
When it happens
Trigger: Calling format() with an empty list, usually from an upstream MultilineAssembler flushing an empty buffer.
Common situations: Flush on empty buffer at file rotation or shutdown; a filter step that removed all lines; passing the result of an empty read straight to the formatter.
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
- event must not be empty
- ACKNOWLEDGE_FAILED
- Already an MDCCallable
- Already an MDCComparator
- Already an MDCConsumer
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/ecf1d94a8c07fd11.
Report an issue: GitHub.
Appendix: source
Thrown at seatunnel-edge-agent/seatunnel-edge-agent-connector/src/main/java/org/apache/seatunnel/edge/agent/connector/file/output/LineOutputFormatter.java:37
import org.apache.seatunnel.shade.com.fasterxml.jackson.core.JsonProcessingException;
import org.apache.seatunnel.shade.com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.seatunnel.shade.com.fasterxml.jackson.databind.node.ArrayNode;
import org.apache.seatunnel.shade.com.fasterxml.jackson.databind.node.ObjectNode;
import org.apache.seatunnel.edge.agent.connector.file.multiline.MultilineAssembler;
import org.apache.seatunnel.edge.agent.connector.record.CollectedRecord;
import java.util.List;
public class LineOutputFormatter implements OutputFormatter {
private final ObjectMapper objectMapper = new ObjectMapper();
@Override
public CollectedRecord format(List<MultilineAssembler.LineElement> event, String sourceId) {
if (event.isEmpty()) {
throw new IllegalArgumentException("event must not be empty");
}
MultilineAssembler.LineElement first = event.get(0);
MultilineAssembler.LineElement last = event.get(event.size() - 1);
try {
String json;
if (event.size() == 1) {
ObjectNode node = buildLineObject(0, first, first.getText());
json = objectMapper.writeValueAsString(node);
} else {
ArrayNode array = objectMapper.createArrayNode();
for (int i = 0; i < event.size(); i++) {
MultilineAssembler.LineElement e = event.get(i);
array.add(buildLineObject(i, e, e.getText()));
}
json = objectMapper.writeValueAsString(array);
}
return new CollectedRecord(
json,View on GitHub (pinned to cf67b549a7)