quarkusio/quarkus · error · IllegalArgumentException
Must set either comment or data
Error message
Must set either comment or data
What it means
OutboundSseEventImpl.Builder.build() validates that an outbound SSE event carries content: at least one of a comment or data must be set. An event with neither would serialize to an empty/invalid SSE frame, so IllegalArgumentException is thrown.
Source
Thrown at independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/jaxrs/OutboundSseEventImpl.java:201
public BuilderImpl data(Object data) {
Objects.requireNonNull(data);
if (data instanceof GenericEntity) {
GenericEntity<?> genericEntity = (GenericEntity<?>) data;
this.type = genericEntity.getRawType();
this.genericType = genericEntity.getType();
this.data = genericEntity.getEntity();
} else {
data(data.getClass(), data);
}
return this;
}
@Override
public OutboundSseEventImpl build() {
if (this.comment == null && this.data == null) {
throw new IllegalArgumentException("Must set either comment or data");
}
return new OutboundSseEventImpl(name, id, reconnectDelay, type, genericType, mediaType, data, comment);
}
}
}
View on GitHub (pinned to e1c734241f)
Solutions
- Call data(...) with a non-null payload before build()
- Or call comment(...) for keep-alive/annotation-only events
- Skip emitting the event entirely when there is no content
- If null data is legitimate, convert it to an explicit empty string or placeholder
Example fix
// before
OutboundSseEvent evt = sse.newEventBuilder()
.name("update")
.build(); // no comment or data
// after
OutboundSseEvent evt = sse.newEventBuilder()
.name("update")
.data(payload != null ? payload : "")
.build(); Defensive patterns
Strategy: validation
Validate before calling
if (eventData == null && eventComment == null) {
throw new IllegalArgumentException("SSE event needs comment or data");
} Try / catch
try { return builder.build(); } catch (IllegalArgumentException e) { if (e.getMessage().equals("Must set either comment or data")) { return builder.data("").build(); } throw e; } Prevention
- Always set data(...) or comment(...) before build()
- Skip event emission when payload is absent
- Default null payloads to an explicit empty string or sentinel
When it happens
Trigger: Building an OutboundSseEvent via newEventBuilder() and calling build() without calling either comment(...) or data(...) — e.g. only setting name/id/reconnectDelay, or conditionally skipping data and leaving it unset.
Common situations: Dynamically built SSE events where a null entity silently skips data(...); refactors that renamed data-setting methods; mapping code that filters out payloads but still emits an event object.
Related errors
- Could not find MessageBodyWriter for ${entityClass}
- Can only work with Quarkus-REST instances: ${sseEventSink}
- Broadcaster has been closed
- Already closed
- Already registered on a broadcaster
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/b98add8a3c69d9d4.
Report an issue: GitHub.