fix(tmdb): repair anilist anime resolution#254
Conversation
Anime lookups ran on the errgroup context, which is canceled once Wait returns, so every AniList request failed and no romaji AKA was ever retrieved. The failures were also swallowed silently, and seasonYear decodes as a number, not a string.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthrough
ChangesAniList metadata resolution
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
AniList enrichment has been fully broken: no anime upload has ever received a romaji AKA or a MAL ID from a title lookup. Two independent bugs each break it on their own.
The context is dead before AniList is ever called
FetchMetadatadoes:errgroupcancels its derived context onceWaitreturns, and every closure returnsnil, so cancellation lands exactly atWait.ResolveAnimethen ran on that cancelled context and every AniList request died withcontext canceledbefore it left the process.requestCtxalready existed for precisely this reason and was already used by the German-title fallback a few lines above;ResolveAnimesimply missed it. Switched torequestCtx.seasonYearis an Int, not a StringanilistQueryselectsseasonYear, which AniList types asInt.anilistMedia.SeasonYearwas declaredstring, so decoding a matched result failed with:doAniListSearchtreats that as a hard failure and the error is not retryable, so the search bailed. Verified against the live API —https://graphql.anilist.coreturns"seasonYear": 1998unquoted. ChangedanilistMedia.SeasonYearandAnimeResult.SeasonYeartoint.This also explains why no test caught it: the fixture in
anilist_test.gohad"seasonYear":"2024"quoted, encoding the bug into the test data. Corrected to a number.Also
Client.anilistURLreplaces the package-level const at the two call sites, so the endpoint can be pointed at a test server.NewClientstill defaults it to the real URL.Tests
TestFetchMetadataResolvesAnimeAKAdrives the realFetchMetadatapath (nested errgroup and all) against an httptest AniList server and asserts both that AniList was actually queried and that the romaji AKA came back. It fails onmainfor either bug alone.Follow-up work (AniList rate limiting and the missing-media contract) is tracked separately.
Summary by CodeRabbit
Bug Fixes
Tests