allegro / hermes

Fast and reliable message broker built on top of Kafka.
http://hermes.allegro.tech
Other
818 stars 218 forks source link

Decimals in JSON subscriptions of Avro topics are invalid #1808

Open moscicky opened 10 months ago

moscicky commented 10 months ago

Test that reproduces the bug: https://github.com/allegro/hermes/commit/b9773ce4bdb0c7ddf5b1edb630e5bd658ec897e9

org.opentest4j.AssertionFailedError: 
expected: "1.20"
 but was: "x"
MateuszDobrowolski commented 3 weeks ago

Can i take care of it? : )

szczygiel-m commented 3 weeks ago

Hi, sure 😄 in case of any questions/problems feel free to ask

MateuszDobrowolski commented 1 week ago

@szczygiel-m I have prepared the proposition of the fix. Could I ask for permission to create a draft PR?

MateuszDobrowolski commented 1 week ago

Proposal: During AVRO-to-JSON conversion, we transform messages with the logical decimal type into a BigDecimal and then into a String. This ensures that subscription consumers receive the decimal value itself rather than the byte buffer contents. This conversion does not apply to AVRO-to-JSON conversion for previews of messages published to the topic. https://github.com/allegro/hermes/pull/1920