grpc / grpc-dart

The Dart language implementation of gRPC.
https://pub.dev/packages/grpc
Apache License 2.0
861 stars 271 forks source link

Map<string, string> DATA_LOSS error with empty string as value for any key #476

Closed Xyzcancer closed 3 years ago

Xyzcancer commented 3 years ago

I'm getting gRPC Error (code: 15, codeName: DATA_LOSS, message: Error parsing response, details: null, rawResponse: null)

version 3.0.0

Repro steps

  1. parse response {"testkey":"", "goodkey":"goodvalue"} for field type map<string,string>

Expected result: Response parsed without errors

Actual result: error code 15 DATA_LOSS

Details

mraleph commented 3 years ago

Without actual runnable reproduction steps or a very detailed description we can't really help you.

The response comes from the server, so there must be something that you are not doing as server expects. Hard to know what exactly without knowing what you are doing and what server expects.

Xyzcancer commented 3 years ago

I/flutter (10265): gRPC Error (code: 15, codeName: DATA_LOSS, message: Error parsing response, details: null, rawResponse: null) #0 _FieldSet._meta (package:protobuf/src/protobuf/field_set.dart:80:36) I/flutter (10265): #1 _FieldSet._nonExtensionInfoByIndex (package:protobuf/src/protobuf/field_set.dart:155:52) I/flutter (10265): #2 FieldSet.$get (package:protobuf/src/protobuf/field_set.dart:423:24) I/flutter (10265): #3 PbMap._mergeEntry (package:protobuf/src/protobuf/pb_map.dart:105:31) I/flutter (10265): #4 _mergeFromCodedBufferReader (package:protobuf/src/protobuf/coded_buffer.dart:189:14) I/flutter (10265): #5 GeneratedMessage.mergeFromCodedBufferReader (package:protobuf/src/protobuf/generated_message.dart:179:5) I/flutter (10265): #6 CodedBufferReader.readMessage (package:protobuf/src/protobuf/coded_buffer_reader.dart:101:13) I/flutter (10265): #7 _mergeFromCodedBufferReader (package:protobuf/src/protobuf/coded_buffer.dart:181:15) I/flutter (10265): #8 GeneratedMessage.mergeFromCodedBufferReader (package:protobuf/src/protobuf/generated_message.dart:179:5) I/flutter (10265): #9 CodedBufferReader.readMessage (package:protobuf/src/protobuf/coded_buffer_reader.dart:101:13) I/flutter (10265): #10 _mergeFromCodedBufferReader (package:protobuf/src/protobuf/coded_buffer.dart:122:15) I/flutter (10265): #11 GeneratedMessage.mergeFromBuffer (package:protobuf/src/protobuf/generatedmessage.dart:194:5) I/flutter (10265): #12 new InitResult.fromBuffer (package:vzaimno/api/grpc/GatewayService.pb.dart:411:128) I/flutter (10265): #13 GatewayServiceClient.$init. (package:vzaimno/api/grpc/GatewayService.pbgrpc.dart:21:54) I/flutter (10265): #14 ClientCall._onResponseData (package:grpc/src/client/call.dart:379:57) I/flutter (10265): #15 _rootRunUnary (dart:async/zone.dart:1362:47) I/flutter (10265): #16 _CustomZone.runUnary (dart:async/zone.dart:1265:19) I/flutter (10265): #17 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1170:7) I/flutter (10265): #18 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11) I/flutter (10265): #19 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7) I/flutter (10265): #20 _SinkTransformerStreamSubscription._add (dart:async/stream_transformers.dart:63:11) I/flutter (10265): #21 _EventSinkWrapper.add (dart:async/stream_transformers.dart:13:11) I/flutter (10265): #22 grpcDecompressor. (package:grpc/src/shared/message.dart:97:10) I/flutter (10265): #23 _HandlerEventSink.add (dart:async/stream_transformers.dart:209:17) I/flutter (10265): #24 _SinkTransformerStreamSubscription._handleData (dart:async/stream_transformers.dart:111:24) I/flutter (10265): #25 _rootRunUnary (dart:async/zone.dart:1362:47) I/flutter (10265): #26 _CustomZone.runUnary (dart:async/zone.dart:1265:19) I/flutter (10265): #27 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1170:7) I/flutter (10265): #28 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11) I/flutter (10265): #29 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7) I/flutter (10265): #30 _SinkTransformerStreamSubscription._add (dart:async/stream_transformers.dart:63:11) I/flutter (10265): #31 _EventSinkWrapper.add (dart:async/stream_transformers.dart:13:11) I/flutter (10265): #32 _GrpcMessageConversionSink._addData (package:grpc/src/shared/streams.dart:100:16) I/flutter (10265): #33 _GrpcMessageConversionSink.add (package:grpc/src/shared/streams.dart:127:7) I/flutter (10265): #34 _ConverterStreamEventSink.add (dart:convert/chunked_conversion.dart:72:18) I/flutter (10265): #35 _SinkTransformerStreamSubscription._handleData (dart:async/stream_transformers.dart:111:24) I/flutter (10265): #36 _rootRunUnary (dart:async/zone.dart:1362:47) I/flutter (10265): #37 _CustomZone.runUnary (dart:async/zone.dart:1265:19) I/flutter (10265): #38 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1170:7) I/flutter (10265): #39 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11) I/flutter (10265): #40 _DelayedData.perform (dart:async/stream_impl.dart:591:14) I/flutter (10265): #41 _StreamImplEvents.handleNext (dart:async/stream_impl.dart:706:11) I/flutter (10265): #42 _PendingEvents.schedule. (dart:async/stream_impl.dart:663:7) I/flutter (10265): #43 _rootRun (dart:async/zone.dart:1346:47) I/flutter (10265): #44 _CustomZone.run (dart:async/zone.dart:1258:19) I/flutter (10265): #45 _CustomZone.runGuarded (dart:async/zone.dart:1162:7) I/flutter (10265): #46 _CustomZone.bindCallbackGuarded. (dart:async/zone.dart:1202:23) I/flutter (10265): #47 _rootRun (dart:async/zone.dart:1354:13) I/flutter (10265): #48 _CustomZone.run (dart:async/zone.dart:1258:19) I/flutter (10265): #49 _CustomZone.runGuarded (dart:async/zone.dart:1162:7) I/flutter (10265): #50 _CustomZone.bindCallbackGuarded. (dart:async/zone.dart:1202:23) I/flutter (10265): #51 _microtaskLoop (dart:async/schedule_microtask.dart:40:21) I/flutter (10265): #52 _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)

Xyzcancer commented 3 years ago

this is messages

message PollValue{ string windowId = 1; map<string, string> form = 2; }

message PersonPollValues{ int64 coBorrowerId = 1; repeated PollValue dbValues = 2; }

Xyzcancer commented 3 years ago

"Poll": { "CoBorrowerId": 0, "DbValues": [ { "WindowId": "personalData", "Form": { "lastName": "Ян", "firstName": "Хх", "middleName": "", "email": "cccc@xxx.me", "birthDate": "1622083842", "gender": "male", "childrensCount": "15", "married": "yes", "oldLastName": "Х" } }, { "WindowId": "pasportData", "Form": { "issueDate": "-1028732400", "serial": "9885", "number": "884258", "policeDepartmentCode": "998-558", "policeDepartment": "ГИМРППП РОРРРМ", "birthPlace": "Жопа", "passportAddress": "Рмппма", "factAddressMatch": "yes", "city": "От Прмсапс" } }, { "WindowId": "contacts", "Form": { "contact_1": "{\"contactName\":\"Ян Го\",\"contactPhone\":\"+7(955)888-85-88\",\"contactType\":\"acquaintance\"}", "contact_2": "{\"contactPhone\":\"+7(900)455-58-76\",\"contactName\":\"Аркадий Ф\",\"contactType\":\"daughter\"}", "contact_3": "{\"contactPhone\":\"+7(953)542-23-51\",\"contactName\":\"Алексей Б\",\"contactType\":\"daughter\",\"isLiveTogether\":\"true\"}" } }, { "WindowId": "privateProperty", "Form": { "flat": "true", "square": "2228", "address": "От Мимммм", "car": "true", "carVin": "Оипппмпvucyyc", "carNumber": "ООО Ипрммм", "carYear": "1996", "carProducer": "Мрка", "carModel": "Мммпролоо" } }, { "WindowId": "incomeSources", "Form": { "incomeSource": "[{\"type\":\"salary\",\"position\":\"Моляр\",\"organizationName\":\"ООО молярия\",\"organizationType\":\"production\",\"organizationAddress\":\"Зуева кукуева\",\"organizationPhone\":\"+7(228)228-22-82\",\"organizationManagerName\":\"В.А.Снеебет\",\"organizationManagerPhone\":\"+7(398)525-88-55\",\"experience\":\"99\",\"officialIncomeValue\":\"228\",\"hasSalaryProof\":\"true\"}]" } }, { "WindowId": "pastLoans", "Form": { "lastTwoYearsLoans": "yes", "sum": "66", "currentLoans": "yes", "wasOverdue": "no" } }, { "WindowId": "cardDetails", "Form": { "cardNumber": "8605 0238 6060 6683", "dueTo": "12/45", "ownerName": "Y T" } }, { "WindowId": "uploadDocuments", "Form": { "vzaimnodocmain": "47dea20d-73e0-4f23-aadd-fbc411947859", "vzaimnodocregistration": "2c92ca07-63ee-42d7-9537-80707a8614aa", "vzaimnoselfi": "34894ada-e2c4-48f7-8d4b-84ab6d9fe95c", "vzaimnodebitcard": "93b5cc33-1c93-48dc-85f1-2374f9194712" } } ] },

Xyzcancer commented 3 years ago

as you can see value of field "middleName" is empty string, that is cause of exception

Xyzcancer commented 3 years ago

@mraleph take another look, please

mraleph commented 3 years ago

@Xyzcancer can you give me the version of the protobuf package that you are using from pubspec.lock?

Xyzcancer commented 3 years ago

@mraleph

protobuf: dependency: "direct main" description: name: protobuf url: "https://pub.dartlang.org" source: hosted version: "2.0.0"

mraleph commented 3 years ago

It's a bug in the protobuf package from what I can see. empty string is special because it is a default value for string type - which means it is not serialized into the message, but this case (when entry has a missing key or value) is not handled correctly: PbMap._mergeEntry creates a fake _FieldSet to deserialize an entry and things break when entryFieldSet.meta is called to compute default value.

I see that somebody already filed a similar issue: https://github.com/dart-lang/protobuf/issues/508 against the package.

Unfortunately protobuf package does not have an active maintainer at the moment, which means it is unlikely that the issue will be resolved very timely :( /cc @mit-mit