Skip to content

fix(metadata): pass parent context to ResolveAnime to avoid canceled ctx#239

Open
HichamLL04 wants to merge 2 commits into
autobrr:mainfrom
HichamLL04:fix/mal-anilist-resolution
Open

fix(metadata): pass parent context to ResolveAnime to avoid canceled ctx#239
HichamLL04 wants to merge 2 commits into
autobrr:mainfrom
HichamLL04:fix/mal-anilist-resolution

Conversation

@HichamLL04

@HichamLL04 HichamLL04 commented Jul 10, 2026

Copy link
Copy Markdown

After the parallel TMDB metadata fan-out (external_ids, translations, videos, keywords, credits), errgroup cancels the derived gctx. ResolveAnime was accidentally receiving this already-canceled context, causing every AniList search to abort immediately and the MAL ID to never be resolved.

Fix: pass the saved requestCtx (captured before errgroup shadowed ctx) so AniList searches run on a live context.

Also fix anilistMedia.SeasonYear JSON field type: the AniList API returns an integer, so parse it as int and convert to string only when non-zero.

Summary by CodeRabbit

  • Bug Fixes
    • Improved anime metadata handling when season year information is unavailable.
    • Corrected season year processing from AniList responses.
    • Improved context handling during anime metadata enrichment.
  • Tests
    • Updated AniList test data to reflect numeric season year responses.
    • Added utilities to improve metadata test logging and input setup.

After the parallel TMDB metadata fan-out (external_ids, translations, videos,
keywords, credits), errgroup cancels the derived gctx. ResolveAnime was
accidentally receiving this already-canceled context, causing every AniList
search to abort immediately and the MAL ID to never be resolved.

Fix: pass the saved requestCtx (captured before errgroup shadowed ctx) so
AniList searches run on a live context.

Also fix anilistMedia.SeasonYear JSON field type: the AniList API returns
an integer, so parse it as int and convert to string only when non-zero.
@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4d316b32-9428-4384-a371-9d016ca983a5

📥 Commits

Reviewing files that changed from the base of the PR and between a5c6ae7 and 089da3c.

📒 Files selected for processing (4)
  • internal/metadata/external_ids_test.go
  • internal/metadata/tmdb/anilist.go
  • internal/metadata/tmdb/anilist_test.go
  • internal/metadata/tmdb/metadata.go

📝 Walkthrough

Walkthrough

AniList season years now decode numerically and are conditionally mapped to metadata. Anime resolution receives the original request context, while tests gain logging and pointer helpers.

Changes

Metadata handling

Layer / File(s) Summary
AniList season-year decoding and mapping
internal/metadata/tmdb/anilist.go, internal/metadata/tmdb/anilist_test.go
AniList seasonYear values decode as integers, are omitted when zero, and are converted to strings when present; the mocked response uses numeric JSON.
Metadata context and test support
internal/metadata/tmdb/metadata.go, internal/metadata/external_ids_test.go
FetchMetadata passes requestCtx to anime resolution, and tests gain level-prefixed logging plus string and integer pointer helpers.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • autobrr/upbrr#232: Also changes the AniList metadata decoding and mapping pipeline.

Suggested reviewers: Audionut

Poem

I hopped through AniList’s year,
Made zero seasons disappear.
With context held just right,
Tests log softly through the night—
Metadata blooms sincere.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: passing the parent context to ResolveAnime to avoid cancellation issues.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant