toProto3JSON doesn't correctly handle map of bytes #103
Labels
priority: p2
Moderately-important priority. Fix may not be included in next release.
size: l
Pull request size is large.
type: bug
Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
We have some protobuf messages that contain fields of type
map<string, bytes>
. Both protobufjs and proto3-json-serializer'sfromProto3JSON
appears to work properly with those fields.However, passing such messages through
toProto3JSON
results in incorrect behaviors while handling thebytes
value.The
bytes
values areBuffer
objects. I would expecttoProto3JSON
to convert them to base64-encoded strings, just like it does for a simplebytes
field.I haven't tested, but from looking at the code, I believe that
repeated bytes
likely suffer from the same incorrect behavior.Environment details
proto3-json-serializer
version: 2.0.0 - 2.0.2Steps to reproduce
Start with the official proto3-json-serializer repo's main branch;
In
test-fixture/proto/test.proto
, modify the messageMessageWithMap
to:message MessageWithMap { map<string, MapValue> map_field = 3; map<string, string> string_map_field = 4; map<string, int64> long_map_field = 5; + map<string, bytes> bytes_map_field = 6; }
In
typescript/test/unit/map.ts
, add this to bothmessage
andjson
:Run tests:
npm test
Observe test failure
The text was updated successfully, but these errors were encountered: