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

  1. Parameterize the input: change CloudEvent to CloudEvent<YourPayloadType>.
  2. If the payload is unstructured, use CloudEvent<String> or CloudEvent<byte[]>.
  3. Ensure the generic argument is not itself a raw type or wildcard that loses the actual class.
  4. 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

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


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/362aafe1b1060b65. Report an issue: GitHub.