kinesalite icon indicating copy to clipboard operation
kinesalite copied to clipboard

Fix invalid record data returned after CBOR-encoded put request

Open dittos opened this issue 5 years ago • 1 comments

Problem

  1. Put record with CBOR-encoded request (e.g. using AWS Java SDK)
  2. Get records -> malformed JSON response
{
    "Records": [
        ...
        {
            "SequenceNumber": "49616645143474350269062001186086684333515393213082370050",
            "ApproximateArrivalTimestamp": 1616506576.795,
            "Data": {
                "type": "Buffer",
                "data": [
                    104,
                    101,
                    108,
                    108,
                    111
                ]
            },
            "PartitionKey": "hello"
        },
        ...
    ],
    ...
}

Data should be base64-encoded string but Buffer object is stringified as-is.

Proposed fix

If Buffer is given as Blob typed parameter, convert it into base64-encoded string.

An alternative approach could be: encode Buffers when writing responses.

Related: #108

dittos avatar Mar 23 '21 13:03 dittos

👍 works for me as well. Any chance this will get merged?

obiwabrakenobi avatar Jun 24 '22 09:06 obiwabrakenobi