thingsboard / dart_thingsboard_client

ThingsBoard API client library for Dart developers.
BSD 3-Clause "New" or "Revised" License
59 stars 30 forks source link

Error: type 'Null' is not a subtype of type 'String' when calling getEntityRelationService().findInfoByQuery #27

Open maksonlee opened 6 months ago

maksonlee commented 6 months ago

Environment

Description Got exception when tried to call getEntityRelationService().findInfoByQuery, the root cause is that 'fromName' of response is null, the same query can be executed fine with REST API.

    RelationsSearchParameters parameters = RelationsSearchParameters(rootId: 'bcbca450-c1a8-11ee-9f93-492ffd078c6c', rootType: EntityType.ASSET);
    RelationEntityTypeFilter filter = RelationEntityTypeFilter('Contains', [EntityType.DEVICE]);
    EntityRelationsQuery query = EntityRelationsQuery(parameters: parameters, filters: [filter]);
    List<EntityRelation> relations = await relationService.findInfoByQuery(query);
D:/flutter/bin/cache/dart-sdk/bin/dart.exe --enable-asserts D:\src\dart_test\bin\dart_test.dart
Error: type 'Null' is not a subtype of type 'String'
Stack: #0      new EntityRelationInfo.fromJson (package:thingsboard_client/src/model/relation_models.dart:183:18)
#1      EntityRelationService.findInfoByQuery.<anonymous closure> (package:thingsboard_client/src/service/entity_relation_service.dart:157:57)
#2      MappedListIterable.elementAt (dart:_internal/iterable.dart:425:31)
#3      ListIterator.moveNext (dart:_internal/iterable.dart:354:26)
#4      new _GrowableList._ofEfficientLengthIterable (dart:core-patch/growable_array.dart:189:27)
#5      new _GrowableList.of (dart:core-patch/growable_array.dart:150:28)
#6      new List.of (dart:core-patch/array_patch.dart:39:18)
#7      ListIterable.toList (dart:_internal/iterable.dart:224:7)
#8      EntityRelationService.findInfoByQuery (package:thingsboard_client/src/service/entity_relation_service.dart:157:70)
<asynchronous suspension>
#9      main (file:///D:/src/dart_test/bin/dart_test.dart:13:38)
<asynchronous suspension>

image