{"record":{"id":"d73d14d44781af2b","repo":"quarkusio/quarkus","slug":"cannot-deserialize-data-for-data-content-encoding","errorCode":null,"errorMessage":"Cannot deserialize data for data-content-encoding: '${dataContentEncoding}'.","messagePattern":"Cannot deserialize data for data-content-encoding: '(.+?)'\\.","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/JsonCloudEventImpl.java","lineNumber":191,"sourceCode":"\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(event.get(\"data\"));\n            return data;\n        } else if (byte[].class.equals(dataType)) {\n            try {\n                if (majorSpecVersion() == 0) {\n                    boolean isBase64 = false;\n                    if (event.has(\"datacontentencoding\")) {\n                        String dce = event.get(\"datacontentencoding\").asText();\n                        if (\"base64\".equals(dce)) {\n                            isBase64 = true;\n                        } else {\n                            throw new RuntimeException(\"Cannot deserialize data for data-content-encoding: '\" + dce + \"'.\");\n                        }\n                    }\n                    if (isBase64) {\n                        if (event.has(\"data\")) {\n                            String txt = event.get(\"data\").asText();\n                            data = (T) Base64.getDecoder().decode(txt);\n                            return data;\n                        } else {\n                            return null;\n                        }\n                    } else {\n                        if (event.has(\"data\")) {\n                            data = (T) mapper.writeValueAsBytes(event.get(\"data\"));\n                            return data;\n                        } else {\n                            return null;\n                        }\n                    }","sourceCodeStart":173,"sourceCodeEnd":209,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/funqy/funqy-knative-events/runtime/src/main/java/io/quarkus/funqy/runtime/bindings/knative/events/JsonCloudEventImpl.java#L173-L209","documentation":"JsonCloudEventImpl.data() deserializes the event's JSON payload. If the JSON contains a 'datacontentencoding' attribute with any value other than 'base64', it cannot handle it and throws a RuntimeException naming the encoding.","triggerScenarios":"Parsing a JSON-serialized CloudEvent whose datacontentencoding is e.g. 'binary', 'utf-8', or any non-base64 string; the code only special-cases 'base64' and throws otherwise.","commonSituations":"Event producers (older SendGrid, custom brokers) set datacontentencoding to values from the 0.1 spec era that modern CloudEvents dropped; hand-crafted event JSON with unexpected fields.","solutions":["Re-publish the event without the datacontentencoding attribute or with 'base64'.","Preprocess the event JSON to remove/normalize the datacontentencoding field before it reaches the binding.","Handle the RuntimeException and fall back to manual decoding of the data field.","Upgrade the event source to CloudEvents 1.0, where datacontentencoding was removed."],"exampleFix":"// before\n{\"specversion\":\"1.0\",\"datacontentencoding\":\"binary\",\"data\":\"...\"}\n// after\n{\"specversion\":\"1.0\",\"data\":\"...\"}","handlingStrategy":"validation","validationCode":"JsonNode dce = event.get(\"datacontentencoding\");\nif (dce != null && !\"base64\".equals(dce.asText())) {\n    throw new IllegalArgumentException(\"Unsupported datacontentencoding: \" + dce.asText());\n}","typeGuard":"boolean isSupportedEncoding(JsonNode event) { JsonNode n = event.get(\"datacontentencoding\"); return n == null || \"base64\".equals(n.asText()); }","tryCatchPattern":"try { data = event.data(dataType); } catch (RuntimeException e) { if (e.getMessage().contains(\"data-content-encoding\")) { data = manualDecode(event.get(\"data\").asText()); } else throw e; }","preventionTips":["Publish events without datacontentencoding (removed in CloudEvents 1.0)","Normalize incoming event JSON to strip legacy encoding fields","Handle base64 only, decode manually otherwise","Update legacy event sources (e.g. old SendGrid webhooks) to spec 1.0"],"tags":["knative","cloudevent","encoding","deserialization","funqy"],"backgroundTag":"unsupported-content-encoding","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}