Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

String and int type mismatched for generated clients #15

Closed
owenthereal opened this issue Aug 26, 2020 · 0 comments
Closed

String and int type mismatched for generated clients #15

owenthereal opened this issue Aug 26, 2020 · 0 comments

Comments

@owenthereal
Copy link
Contributor

owenthereal commented Aug 26, 2020

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.

owenthereal added a commit to owenthereal/tdlib that referenced this issue Aug 26, 2020
For some reason, int64 is returned as string from the Telegram server.
Adjust the generator to generate string type for int64 fields.

This fixes i-Naji#15.
owenthereal added a commit to owenthereal/tdlib that referenced this issue Aug 26, 2020
For some reason, int64 is returned as string from the Telegram server.
Adjust the generator to generate string type for int64 fields.

This fixes i-Naji#15.
owenthereal added a commit to owenthereal/tdlib that referenced this issue Aug 26, 2020
For some reason, int64 is returned as string from the Telegram server.
Adjust the generator to generate string type for int64 fields.

This fixes i-Naji#15.
@i-Naji i-Naji closed this as completed Nov 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants