akhq icon indicating copy to clipboard operation
akhq copied to clipboard

Decimals are not parsed correctly

Open florianmutter opened this issue 3 years ago • 5 comments

If I have a schema with a decimal like this (example from the code):

{
    "name": "Dog",
    "namespace": "org.akhq",
    "type": "record",
    "fields" : [
        {"name": "id", "type": "int"},
        {"name": "name", "type": "string"},
        {"name": "weight", "type" : { "type" : "bytes", "logicalType" : "decimal", "precision" : 4, "scale" : 2}}
    ]
}

and I create a message with decimal 1.00 like this:

{
  "id": 1,
  "name": "Doggy",
  "weight": 1.0
}

The message is displayed in the extended json view like this:

{
  "id": 1,
  "name": "Doggy",
  "weight": 1
}

This json can then not be used to send the message again because it cannot serialize 1.

While testing I got two different errors:

Uncaught (in promise) 
Object { status: 500, message: "Internal Server Error: Cannot serialize value", stacktrace: null }

And

Uncaught (in promise) 
Object { status: 500, message: "Internal Server Error: Expected bytes. Got VALUE_NUMBER_INT", stacktrace: null }
​

We also had the case that it did accept the message but created a big decimal like 251235313.123 from the input 1 but I cannot reproduce this.

florianmutter avatar Jan 28 '22 08:01 florianmutter

Hmm now that I tried it again, just to be sure it worked like expected. They I only wonder how we did manage to create this random number when sending the same message that was displayed again to the topic...

florianmutter avatar Jan 28 '22 08:01 florianmutter

Hi,

I am facing the same issue with Double fields.

So if I get one of the messages from AKHQ and try to publish it again, it shows the error as below so I need to add ".0" and it will work.

image

fabiofilz avatar Jan 28 '22 15:01 fabiofilz

Hi, i will like to know if it's possible to get this issue assigned :>

IsaacNoga avatar May 28 '22 19:05 IsaacNoga

done @IsaacNoga enjoy ;)

tchiotludo avatar May 28 '22 19:05 tchiotludo

Experiencing the same problems. Any progress in fixing it, @IsaacNoga ?

neoscaler avatar Jul 08 '22 14:07 neoscaler

Root cause for the described issue seems to be that the value is parsed and then stringified. See here:

https://github.com/tchiotludo/akhq/blob/e57cc02c790ae833f1e2fd4f77b5cbe8def03c96/client/src/containers/Topic/Topic/TopicData/TopicData.jsx#L929-L934

tristanexsquare avatar Nov 01 '22 16:11 tristanexsquare