-
Notifications
You must be signed in to change notification settings - Fork 678
toProto3JSON doesn't correctly handle map of bytes #7704
Copy link
Copy link
Open
Labels
library: google-cloud-node-coreIssues transferred from another repositoryIssues transferred from another repositorypriority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Metadata
Metadata
Assignees
Labels
library: google-cloud-node-coreIssues transferred from another repositoryIssues transferred from another repositorypriority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Type
Fields
Give feedbackNo fields configured for issues without a type.
We have some protobuf messages that contain fields of type
map<string, bytes>. Both protobufjs and proto3-json-serializer'sfromProto3JSONappears to work properly with those fields.However, passing such messages through
toProto3JSONresults in incorrect behaviors while handling thebytesvalue.The
bytesvalues areBufferobjects. I would expecttoProto3JSONto convert them to base64-encoded strings, just like it does for a simplebytesfield.I haven't tested, but from looking at the code, I believe that
repeated byteslikely suffer from the same incorrect behavior.Environment details
proto3-json-serializerversion: 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 messageMessageWithMapto: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 bothmessageandjson:'minus one': '-1', zero: '0', }, + bytesMapField: { + key1: 'dmFsdWUgMQo=', + key2: 'dmFsdWUgMgo=', + }, };Run tests:
npm testObserve test failure