Closed murrayirrigation closed 6 months ago
Hi @murrayirrigation. This error is avsc
protecting you from incorrect data: toBuffer
expects its input buffer to contain exactly one value's encoding. If additional data is expected in the buffer, you can replace it with decode
:
const {value, offset} = type.decode(buf);
value
will contain the decoded value, and offset
the start of the trailing data. You may for example want to check that buf
only contains zero after it.
I have a simple key value schema
When I attempt to decode:
I get get a buffer in the messages 4096 long full of 0s after the data. If I don't trim it the fromBuffer throws an error about trailing 0s. ,"stack":"Error: trailing data\n I can remove trailing 0s and it works, I've verified encoding and decoding in python. I'm not super happy removing trailing 0s because what if the last encoded utf8 is validly 0? Should the keySchema/valueSchema not just provide a length or something?
I feel like this isn't expected behaviour?