Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't recover from structured CloudEvents with invalid JSON #2492

Open
ntkoopman opened this issue Feb 21, 2024 · 5 comments
Open

Can't recover from structured CloudEvents with invalid JSON #2492

ntkoopman opened this issue Feb 21, 2024 · 5 comments
Labels
bug Something isn't working kafka

Comments

@ntkoopman
Copy link

When receiving a structured CloudEvent, the payload is converted to JSON by KafkaCloudEventHelper#createFromStructuredCloudEvent. If the actual data is not valid JSON, this throws an exception which is handled in KafkaSource by immediately closing the connection.

Both the value-deserialization-failure-handler and failure-strategy are never invoked, and since this is before any application code, it seems impossible to handle this failure case.

@cescoffier
Copy link
Contributor

It should be considered as a deserialization failure. So definitely a bug.

Could you provide an example of such broken cloud events?

@cescoffier cescoffier added bug Something isn't working kafka labels Feb 21, 2024
@ntkoopman
Copy link
Author

Any invalid JSON will do:

content-type: application/cloudevents+json

{"type":

@ozangunalp
Copy link
Collaborator

ozangunalp commented Feb 22, 2024

An option is to use the io.quarkus.kafka.client.serialization.JsonObjectDeserializer which would do the Json parsing on the Kafka client and the failure handler and failure strategy would work as expected.
Is there anything preventing you to use the JsonObject deserializer?

We may imagine a way to invoke the failure-strategy but once you use the StringDeserializer it is not possible to catch this in the value-deserialization-failure-handler.

@ntkoopman
Copy link
Author

Using JsonObjectDeserializer would make it impossible to handle binary messages on the same topic. Just to be clear, I don't need a work around, I got it working by using the CloudEvents SDK deserializer.

One side effect in Quarkus, is that it also triggers the liveness and readiness checks to fail, effectively causing a denial of service.

@cescoffier
Copy link
Contributor

It still needs to be fixed in reactive messaging. The SDK is not very Quarkus friendly (native issues, detection, reflection...). It works, but may lead to issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working kafka
Projects
None yet
Development

No branches or pull requests

3 participants