SkyBridge
SkyBridge copied to clipboard
UTF-8 error in facet processing
skybridge | ERROR - 2024-11-16 18:08:40.670123
skybridge | GET /api/v1/timelines/home?limit=40&min_id=1968935019812487168
skybridge | Error thrown by handler.
skybridge | FormatException: Unfinished UTF-8 octet sequence (at offset 13)
skybridge | dart:convert Utf8Codec.decode
skybridge | package:sky_bridge/facets.dart 104 processFacets
skybridge | package:sky_bridge/models/mastodon/mastodon_post.dart 81 MastodonPost.fromFeedView
skybridge | dart:collection SetBase.toList
skybridge | build/routes/api/v1/timelines/list/[id].dart 51 onRequest.<fn>
skybridge | package:sky_bridge/database.dart 18 databaseTransaction
skybridge | build/routes/api/v1/timelines/home.dart 43 onRequest
While processing a post, it looks like BlueSky can return some improperly formatted content. The issue is that this exception causes no further posts to show up in Ivory. The workaround is to reset the cache in the Ivory client, but ideally SkyBridge should just skip the the bad post and continue processing.
Making the list processing in routes/api/v1/timelines/list/[id].dart more resilient to a bad post is the best way to handle it
// Take all the posts and convert them to Mastodon ones
// Await all the futures, getting any necessary data from the database.
final posts = await databaseTransaction(() async {
final futures = feed.data.feed.map(MastodonPost.fromFeedView).toList();
return Future.wait(futures);
});