{"record":{"id":"29b261604bc5b1ee","repo":"quarkusio/quarkus","slug":"don-t-know-how-to-get-event-data-datacontenttype","errorCode":null,"errorMessage":"Don't know how to get event data (dataContentType: '%s', javaType: '%s').","messagePattern":"Don't know how to get event data \\(dataContentType: '(.+?)', javaType: '(.+?)'\\)\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"extensions/funqy/funqy-knative-events/runtime/src/main/java/io/quarkus/funqy/runtime/bindings/knative/events/HeaderCloudEventImpl.java","lineNumber":178,"sourceCode":"\n        return dataContentType;\n    }\n\n    @Override\n    public T data() {\n        if (data != null) {\n            return data;\n        }\n        if (dataContentType() != null && dataContentType().startsWith(\"application/json\") && !byte[].class.equals(dataType)) {\n            data = reader.readValue(buffer.getBytes());\n            return data;\n        } else if (byte[].class.equals(dataType)) {\n            data = (T) buffer.getBytes();\n            return data;\n        } else {\n            String msg = String.format(\"Don't know how to get event data (dataContentType: '%s', javaType: '%s').\",\n                    dataContentType(), dataType.getTypeName());\n            throw new RuntimeException(msg);\n        }\n    }\n}\n","sourceCodeStart":160,"sourceCodeEnd":182,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/funqy/funqy-knative-events/runtime/src/main/java/io/quarkus/funqy/runtime/bindings/knative/events/HeaderCloudEventImpl.java#L160-L182","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nMyPojo p = event.data(MyPojo.class);\n// after\nString raw = event.data(String.class);\nMyPojo p = new ObjectMapper().readValue(raw, MyPojo.class);","handlingStrategy":"type-guard","validationCode":"if (!(String.class.equals(dataType) || byte[].class.equals(dataType))) {\n    throw new IllegalArgumentException(\"HeaderCloudEventImpl supports only String or byte[] data: \" + dataType);\n}","typeGuard":"boolean headerDataSupported(Class<?> t) { return t == String.class || t == byte[].class; }","tryCatchPattern":"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; }","preventionTips":["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"],"tags":["knative","cloudevent","deserialization","funqy"],"backgroundTag":"unsupported-event-data-type","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}