AniTrend / anitrend-v2

Rewrite project for AniTrend 🔥
GNU General Public License v3.0
45 stars 6 forks source link

[app-data-jikan] Fix DTO structure for JikanRemoteSource #239

Closed wax911 closed 1 year ago

wax911 commented 1 year ago

AniTrend Issue Guidelines

Before opening a new issue, please take a moment to review our community guidelines to make the contribution process easy and effective for everyone involved.

You may find an answer in already closed issues: https://github.com/AniTrend/anitrend-v2/issues?q=is%3Aissue+is%3Aclosed

Description of Bug

After migrating from the jikan v3 to Jikan v4 endpoint, we started seeing an increase in errors reported by the AbstractNetworkClient -> OnlineStrategy.

See:

Additional Context

kotlinx.serialization.MissingFieldException: Fields [source, rating, episodes, duration, premiered, broadcast, trailer_url, producers, licensors, studios, opening_themes, ending_themes, mal_id, url, image_url, title, title_english, title_japanese, title_synonyms, type, airing, synopsis, background] are required for type with serial name 'co.anitrend.data.jikan.media.model.anime.JikanMediaModel.Anime', but they were missing at path: $
    at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableValue(StreamingJsonDecoder.kt:90)
    at kotlinx.serialization.json.Json.decodeFromString(Json.kt:95)
    at com.jakewharton.retrofit2.converter.kotlinx.serialization.Serializer$FromString.fromResponseBody(Serializer.kt:30)
    at com.jakewharton.retrofit2.converter.kotlinx.serialization.DeserializationStrategyConverter.convert(DeserializationStrategyConverter.kt:11)
    at com.jakewharton.retrofit2.converter.kotlinx.serialization.DeserializationStrategyConverter.convert(DeserializationStrategyConverter.kt:7)
    at retrofit2.OkHttpCall.parseResponse(OkHttpCall.java:243)
    at retrofit2.OkHttpCall$1.onResponse(OkHttpCall.java:153)
    at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:519)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
    at java.lang.Thread.run(Thread.java:923)

As shown above, the root element of Jikan now uses a data key, which encloses all the fields reported in the exception.

Action items:

wax911 commented 1 year ago

Closing this off as the new serverless function will deprecated embedded sources like jikan