Kaiteki-Fedi / Kaiteki

The comfy SNS client for everything, everywhere
https://kaiteki.app
GNU Affero General Public License v3.0
488 stars 31 forks source link

[friendica] Returned array instead of object on /api/v1/markers #475

Closed kr428 closed 11 months ago

kr428 commented 11 months ago

Error Type

_TypeError

Error Message

type 'List' is not a subtype of type 'Map<String, dynamic>' in type cast

Stack Trace

#0      KaitekiResponseExtensions.fromJson (package:kaiteki_core/src/http/extensions.dart:16)
#1      KaitekiJsonDeserializationResopnseExtensions.fromResponse (package:kaiteki_core/src/http/extensions.dart:28)
#2      KaitekiJsonDeserializationResopnseExtensions.fromResponse.<anonymous closure> (package:kaiteki_core/src/http/extensions.dart:28)
<asynchronous suspension>
#3      SharedMastodonAdapter.getNotifications (package:kaiteki_core/src/social/backends/mastodon/shared_adapter.dart:398)
<asynchronous suspension>
#4      NotificationService.build (package:kaiteki/fediverse/services/notifications.dart:51)
<asynchronous suspension>
#5      FutureHandlerProviderElementMixin.handleFuture.<anonymous closure>.<anonymous closure> (package:riverpod/src/async_notifier/base.dart:339)
<asynchronous suspension>

Additional information

Platform: android: SP1A.210812.016.M515FXXS5DWG1 Version: Weekly 2023-47 (1700441989) Backend: (loma.ml, MastodonAdapter, ApiType.mastodon)

kr428 commented 11 months ago

Note: This is related to a Friendica backend. Not sure where to best report such issues. Cc'ing @annando ? This is most likely a difference in Friendicas Mastodon API implementation?

MrPetovan commented 11 months ago

We would need to see a sample of the JSON document that triggered the error to be able to troubleshoot this error.

Craftplacer commented 11 months ago

A few lines in source code: https://github.com/Kaiteki-Fedi/Kaiteki/blob/weekly-2023-47/src/kaiteki_core/lib/src/social/backends/mastodon/shared_adapter.dart#L398 https://github.com/Kaiteki-Fedi/Kaiteki/blob/master/src/kaiteki_core/lib/src/social/backends/mastodon/client.dart#L378

Craftplacer commented 11 months ago

Also reading the API docs (https://docs.joinmastodon.org/methods/markers/#get) friendica must be returning everything but the expected object.

Craftplacer commented 11 months ago

Reading the linked issue, it seems to be fixed on Friendica's side.

MrPetovan commented 11 months ago

Our API endpoint was wrongly returning an empty array [] when we didn't have available markers, now it just returns an empty object {} which may or may not trip the markers.notifications lookup: https://github.com/Kaiteki-Fedi/Kaiteki/blob/b6c6fc339a895c6dabbb4e27032feec2de1d08a9/src/kaiteki_core/lib/src/social/backends/mastodon/shared_adapter.dart#L397-L399

Craftplacer commented 11 months ago

It shouldn't since the object properties are nullable.

MrPetovan commented 11 months ago

A Friendica user has successfully tested the updated endpoint with Kaiteki! 🎉