quarkusio/quarkus · error · RuntimeException
Don't know how to get event data (dataContentType: '%s', jav
Error message
Don't know how to get event data (dataContentType: '%s', javaType: '%s').
What it means
HeaderCloudEventImpl.data() extracts the event payload from HTTP headers/buffer. It supports only a few data types (e.g. String and byte[]); when the requested Java type (dataType) does not match the dataContentType or is otherwise unsupported, it throws a RuntimeException describing the content type and target type.
Source
Thrown at extensions/funqy/funqy-knative-events/runtime/src/main/java/io/quarkus/funqy/runtime/bindings/knative/events/HeaderCloudEventImpl.java:178
return dataContentType;
}
@Override
public T data() {
if (data != null) {
return data;
}
if (dataContentType() != null && dataContentType().startsWith("application/json") && !byte[].class.equals(dataType)) {
data = reader.readValue(buffer.getBytes());
return data;
} else if (byte[].class.equals(dataType)) {
data = (T) buffer.getBytes();
return data;
} else {
String msg = String.format("Don't know how to get event data (dataContentType: '%s', javaType: '%s').",
dataContentType(), dataType.getTypeName());
throw new RuntimeException(msg);
}
}
}
View on GitHub (pinned to e1c734241f)
Solutions
- Use String.class or byte[].class for the data access, then deserialize manually with Jackson/ObjectMapper.
- Ensure the function signature's input type matches a supported mapping (POJOs work only via the JSON CloudEvent implementation).
- Set Content-Type to application/json so the JSON CloudEvent implementation handles POJO deserialization.
- Add explicit handling in the function for raw String input and map it to a POJO yourself.
Example fix
// before MyPojo p = event.data(MyPojo.class); // after String raw = event.data(String.class); MyPojo p = new ObjectMapper().readValue(raw, MyPojo.class);
Defensive patterns
Strategy: type-guard
Validate before calling
if (!(String.class.equals(dataType) || byte[].class.equals(dataType))) {
throw new IllegalArgumentException("HeaderCloudEventImpl supports only String or byte[] data: " + dataType);
} Type guard
boolean headerDataSupported(Class<?> t) { return t == String.class || t == byte[].class; } Try / catch
try { T d = event.data(dataType); } catch (RuntimeException e) { if (e.getMessage().startsWith("Don't know how to get event data")) { String raw = event.data(String.class); return manuallyMap(raw); } throw e; } Prevention
- Only request String or byte[] from header-based events
- Ensure Content-Type is application/json for POJO payloads
- Inspect ce-datacontenttype before choosing the data type
- Prefer the JSON CloudEvent binding for typed access
When it happens
Trigger: Invoking data(SomePojo.class) (or another unsupported type) on a HeaderCloudEventImpl whose buffered data is only convertible to String or byte[], with a dataContentType like application/json but a non-String/byte[] target.
Common situations: A Funqy Knative function declares a POJO input while the binding path populated a header-based CloudEvent that only buffers raw bytes/strings; mismatched datacontenttype (e.g. text/plain) vs declared Java type.
Related errors
- Cannot deserialize data for data-content-encoding: '${dataCo
- Don't know how to get event data (dataContentType: '%s', jav
- Only supported major versions are 0 and 1.
- Function for trigger '${trigger}' has multiple matching invo
- When using CloudEvent<> generic parameter must be used.
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/29b261604bc5b1ee.
Report an issue: GitHub.