ConnectyCube / connectycube-flutter-sdk-releases

ConnectyCube Flutter SDK Releases
7 stars 1 forks source link

type 'int' is not a subtype of type 'String?' #68

Closed amitkhairnar44 closed 2 years ago

amitkhairnar44 commented 2 years ago

Platform (use [x]) [x] Android [x] iOS [ ] macOS [ ] Windows [ ] Web

Describe the bug: There is some json parsing issue while creating a CubeDialog with recipients which are created using signInUsingFirebase.

The createDialog function is failing due to parsing issue of the name object. Current code expects it to be String but the api is returning an int.

I think the issue occurs only if the recipients are created using signInUsingFirebase.

Steps to Reproduce:

  1. Create User using signInUsingFirebase Firebase Auth (Mobile OTP based)
  2. Try to create a dialog using the created user (Most of the data is null since user is signed up using firebase mobile auth)

Logs:

Data from api request:
{
"_id":"61a602efd2b6d50012f88b41",
"user_id":5181004,
"created_at":"2021-11-30T10:54:39Z",
"updated_at":"2021-11-30T10:54:39Z",
"name":5180981,
"type":3,
"photo":null,
"occupants_ids":[5180981,5181004],
"occupants_count":2,
"is_e2ee":false,
"is_muted":false,
"last_message":null,
"last_message_date_sent":null,
"last_message_id":null,
"last_message_user_id":null,
"last_message_status":null,
"unread_messages_count":0,
"pinned_messages_ids":[],
"description":null,
"xmpp_room_jid":null,
"admins_ids":[]
}
Error:
Unhandled Exception: type 'int' is not a subtype of type 'String?'
new CubeDialog.fromJson (package:connectycube_sdk/src/chat/models/cube_dialog.dart:47:5)
CreateDialogQuery.processResult (package:connectycube_sdk/src/chat/query/dialogs_query.dart:73:23)
Query.perform.<anonymous closure> (package:connectycube_sdk/src/core/rest/query/query.dart:61:28)
_rootRunUnary (dart:async/zone.dart:1436:47)
_CustomZone.runUnary (dart:async/zone.dart:1335:19)

Actual result: Unable to parse the json because the value of name is an int 5180981 Expected behavior: It should be able to parse the user data by detecting the value.

You can check if the value of name is String or not and then parse.

name = json['name'] != null ? ( json['name'] is String)  ? json['name'] :  json['name'].toString() : null;
TatankaConCube commented 2 years ago

thank you for reporting it, will notify the server-side team about it

TatankaConCube commented 2 years ago

@amitkhairnar44 server-side team reported that they fixed this issue today, please check on your side

amitkhairnar44 commented 2 years ago

@TatankaConCube I'll check and let you know

amitkhairnar44 commented 2 years ago

@TatankaConCube The issue is fixed 👍🏼

amitkhairnar44 commented 2 years ago

@TatankaConCube Now I'm getting the same issue while fetching dialogs

The getDialogs() api is having same json parsing issue

type 'int' is not a subtype of type 'String?'

#0      new CubeDialog.fromJson (package:connectycube_sdk/src/chat/models/cube_dialog.dart:47:5)
#1      GetDialogsQuery.processResult.<anonymous closure> (package:connectycube_sdk/src/chat/query/dialogs_query.dart:38:43)
#2      MappedListIterable.elementAt (dart:_internal/iterable.dart:413:31)
#3      ListIterator.moveNext (dart:_internal/iterable.dart:342:26)
#4      new _GrowableList._ofEfficientLengthIterable (dart:core-patch/growable_array.dart:188:27)
#5      new _GrowableList.of (dart:core-patch/growable_array.dart:150:28)
#6      new List.of (dart:core-patch/array_patch.dart:50:28)
#7      ListIterable.toList (dart:_internal/iterable.dart:213:44)
#8      new PagedResult (package:connectycube_sdk/src/core/rest/response/paged_result.dart:25:40)
#9      GetDialogsQuery.processResult (package:connectycube_sdk/src/chat/query/dialogs_query.dart:37:12)
#10     Query.perform.<anonymous closure> (package:connectycube_sdk/src/core/rest/query/query.dart:61:28)
#11     _rootRunUnary (dart:async/zone.dart:1436:47)
#12     _CustomZone.runUnary (dart:async/zone.dart:1335:19)
TatankaConCube commented 2 years ago

sorry for that, the server-side team reverted some commits on the backend including this fix, they promise to back it as fast as possible

TatankaConCube commented 2 years ago

should have been fixed, please check one more time

amitkhairnar44 commented 2 years ago

@TatankaConCube I'll check and inform you

amitkhairnar44 commented 2 years ago

@TatankaConCube The issue seems to be fixed 👍🏼