quarkusio/quarkus · error · RuntimeException
When using CloudEvent<> generic parameter must be used.
Error message
When using CloudEvent<> generic parameter must be used.
What it means
When a Funqy Knative function's input type is a raw CloudEvent without a generic parameter, the binding cannot determine the CE data type and throws this RuntimeException. CloudEvent must be parameterized (e.g. CloudEvent<MyPojo>) so the payload type is captured in the binding context.
Source
Thrown at extensions/funqy/funqy-knative-events/runtime/src/main/java/io/quarkus/funqy/runtime/bindings/knative/events/KnativeEventsBindingRecorder.java:124
throw new IllegalStateException("Function for trigger '" + trigger + "' has multiple matching invokers");
}
v.add(invoker);
return v;
});
if (invoker.hasInput()) {
Type inputType = invoker.getInputType();
if (CloudEvent.class.equals(Reflections.getRawType(inputType))) {
if (inputType instanceof ParameterizedType) {
Type[] params = ((ParameterizedType) inputType).getActualTypeArguments();
if (params.length == 1) {
inputType = params[0];
invoker.getBindingContext().put(INPUT_CE_DATA_TYPE, inputType);
}
} else {
throw new RuntimeException("When using CloudEvent<> generic parameter must be used.");
}
}
validateNotBoxedByteArray(inputType, invoker.getName(), "input");
JavaType javaInputType = objectMapper.constructType(inputType);
ObjectReader reader = objectMapper.readerFor(javaInputType);
invoker.getBindingContext().put(DATA_OBJECT_READER, reader);
QueryReader queryReader = queryMapper.readerFor(inputType);
invoker.getBindingContext().put(QueryReader.class.getName(), queryReader);
}
if (invoker.hasOutput()) {
Type outputType = invoker.getOutputType();
if (CloudEvent.class.equals(Reflections.getRawType(outputType))) {
if (outputType instanceof ParameterizedType) {
Type[] params = ((ParameterizedType) outputType).getActualTypeArguments();
if (params.length == 1) {View on GitHub (pinned to e1c734241f)
Solutions
- Parameterize the input: change CloudEvent to CloudEvent<YourPayloadType>.
- If the payload is unstructured, use CloudEvent<String> or CloudEvent<byte[]>.
- Ensure the generic argument is not itself a raw type or wildcard that loses the actual class.
- Keep the declared type parameter concrete so init can put INPUT_CE_DATA_TYPE into the binding context.
Example fix
// before
public void handle(CloudEvent event) { ... }
// after
public void handle(CloudEvent<MyPojo> event) { ... } Defensive patterns
Strategy: type-guard
Validate before calling
Type t = method.getGenericParameterTypes()[0];
if (t instanceof ParameterizedType pt && pt.getRawType() == CloudEvent.class
&& pt.getActualTypeArguments().length == 1
&& !(pt.getActualTypeArguments()[0] instanceof WildcardType)) {
// ok: concrete CloudEvent<T>
} Type guard
boolean isConcreteCloudEvent(Type t) {
return t instanceof ParameterizedType pt
&& pt.getRawType() == CloudEvent.class
&& pt.getActualTypeArguments().length == 1
&& !(pt.getActualTypeArguments()[0] instanceof WildcardType);
} Try / catch
try { registry.init(...); } catch (RuntimeException e) { if (e.getMessage().contains("CloudEvent<> generic parameter must be used")) { log.error("Parameterize CloudEvent input, e.g. CloudEvent<Pojo>", e); } throw e; } Prevention
- Always write CloudEvent<T> with a concrete T
- Enable -Xlint:rawtypes and treat raw-type warnings as errors
- Add an ArchUnit/unit test rejecting raw CloudEvent parameters
- Avoid wildcards in function signatures
When it happens
Trigger: A function is declared with input CloudEvent (raw type) or CloudEvent with zero type arguments while init inspects the generic parameterization; the else branch throws because getActualTypeArguments() is empty/invalid.
Common situations: Developers write CloudEvent to 'keep it generic' or after an IDE strips imports/type args; code migrated from plain Funqy without adding the generic parameter.
Related errors
- Only supported major versions are 0 and 1.
- Don't know how to get event data (dataContentType: '%s', jav
- Cannot deserialize data for data-content-encoding: '${dataCo
- Don't know how to get event data (dataContentType: '%s', jav
- Function for trigger '${trigger}' has multiple matching invo
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/362aafe1b1060b65.
Report an issue: GitHub.