i-Naji/tdlib

String and int type mismatched for generated clients

Closed this issue · 0 comments

There seems to be some inconsistency between the types returned by the Telegram server and the definition. For example, I got the following error:

I/flutter ( 6625): res =>>>> {@type: updateConnectionState, state: {@type: connectionStateReady}}
E/flutter ( 6625): [ERROR:flutter/lib/ui/ui_dart_state.cc(171)] Unhandled Exception: type 'String' is not a subtype of type 'int'
E/flutter ( 6625): #0      new ProfilePhoto.fromJson (package:tdlib/src/tdapi/objects/profile_photo.dart:21:10)
E/flutter ( 6625): #1      new User.fromJson (package:tdlib/src/tdapi/objects/user.dart:64:38)
E/flutter ( 6625): #2      new UpdateUser.fromJson (package:tdlib/src/tdapi/objects/update.dart:1598:22)
E/flutter ( 6625): #3      allObjects.<anonymous closure> (package:tdlib/src/tdapi/tdapi.dart:1484:37)
E/flutter ( 6625): #4      convertToObject (package:tdlib/src/tdapi/convertor.dart:6:48)
E/flutter ( 6625): #5      TdClient.clientEvents.<anonymous closure> (package:tdlib/src/tdclient/tdclient.dart:39:25)
E/flutter ( 6625): #6      _MapStream._handleData (dart:async/stream_pipe.dart:219:31)
E/flutter ( 6625): #7      _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:157:13)
E/flutter ( 6625): #8      _rootRunUnary (dart:async/zone.dart:1198:47)
E/flutter ( 6625): #9      _CustomZone.runUnary (dart:async/zone.dart:1100:19)
E/flutter ( 6625): #10     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1005:7)
E/flutter ( 6625): #11     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:357:11)
E/flutter ( 6625): #12     _DelayedData.perform (dart:async/stream_impl.dart:611:14)
E/flutter ( 6625): #13     _StreamImplEvents.handleNext (dart:async/stream_impl.dart:730:11)
E/flutter ( 6625): #14     _PendingEvents.schedule.<anonymous closure> (dart:async/stream_impl.dart:687:7)
E/flutter ( 6625): #15     _rootRun (dart:async/zone.dart:1182:47)
E/flutter ( 6625): #16     _CustomZone.run (dart:async/zone.dart:1093:19)
E/flutter ( 6625): #17     _CustomZone.runGuarded (dart:async/zone.dart:997:7)
E/flutter ( 6625): #18     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1037:23)
E/flutter ( 6625): #19     _rootRun (dart:async/zone.dart:1190:13)
E/flutter ( 6625): #20     _CustomZone.run (dart:async/zone.dart:1093:19)
E/flutter ( 6625): #21     _CustomZone.runGuarded (dart:async/zone.dart:997:7)
E/flutter ( 6625): #22     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1037:23)
E/flutter ( 6625): #23     _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
E/flutter ( 6625): #24     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
E/flutter ( 6625):

According to the API definition (https://github.com/i-Naji/tdlib/blob/master/data/td_api.tl#L315 as well as upstream https://github.com/tdlib/td/blob/master/td/generate/scheme/td_api.tl#L315), ProfilePhoto.id is an int. But I'm getting the error above. I'm wondering whether the upstream definition is out of date with the Telegram server for some reason. BTW, there are quite some types that have the string to int mismatch issue when running the example in this repo.