Skip to content

fix(metadata): don't promote season/episode 404s to item-level stale provider IDs - #35

Merged
Quick104 merged 2 commits into
Silo-Server:mainfrom
fluxis:fix/season-404-not-item-stale
Jun 6, 2026
Merged

Quick104 merged 2 commits into
Silo-Server:mainfrom
fluxis:fix/season-404-not-item-stale

Conversation

@fluxis

@fluxis fluxis commented Jun 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The main-refresh path in MetadataService.processInternal passes provider404s to handleProvider404 for season and episode fetch errors. Since handleProvider404 records the item's provider ID as stale whenever provider404s != nil, a 404 fetching seasons or episodes promotes the item itself to stale — even though the 404 is a child-resource failure (TMDB returns 404 for /tv/{id}/season/0 when the series has no specials season; for episodes that haven't aired yet; etc.).

The equivalent target-refresh paths (fetchTargetSeasonResults and fetchTargetEpisodeResults) already pass nil for this exact reason. This PR brings the main-refresh path in line with the existing target-refresh pattern.

Diff

Two call sites in internal/metadata/service.go:

Line Resource Before After
1140 Seasons (main refresh) handleProvider404(provider404s, ...) handleProvider404(nil, ...)
1173 Episodes (main refresh) handleProvider404(provider404s, ...) handleProvider404(nil, ...)

For reference, the already-correct sites that this fix matches:

  • service.go:2305 — fetchTargetSeasonResults, already passes nil
  • service.go:2339 — fetchTargetEpisodeResults, already passes nil

Observed impact

On our deployment, the bug caused 13,524 series items to have their media_items.tmdb_id cleared and recorded as stale during a single library refresh sweep — every series whose TMDB entry doesn't have a "specials" season (most anime, many older shows) was affected. Once recorded, suppressRecordedStaleProviderIDs locked the items out of future TMDB enrichment, so subsequent refreshes couldn't self-heal even when TVDB supplied a working TMDB cross-reference.

The bug is fully reproducible. Live log capture during a refresh sweep:

provider=tmdb content_id=... season=0 provider_id=62913 error="...tmdb: HTTP 404..."
provider=tmdb content_id=... season=0 provider_id=72511 error="...tmdb: HTTP 404..."
provider=tmdb content_id=... season=0 provider_id=75778 error="...tmdb: HTTP 404..."

Every single 404 has season=0. Direct curl tests confirm:

id=68417: GET /tv/68417 → 200   /season/0 → 404   /season/1 → 200
id=76645: GET /tv/76645 → 200   /season/0 → 404   /season/1 → 200
id=80836: GET /tv/80836 → 200   /season/0 → 404   /season/1 → 200
id=43249: GET /tv/43249 → 200   /season/0 → 200   /season/1 → 200
id=110126: GET /tv/110126 → 200   /season/0 → 404   /season/1 → 200

The TMDB IDs themselves are valid. Only the specials-season fetch 404s.

Why this regressed

The target-refresh paths (lines 2305/2339) already use nil for season/episode child fetches. The main-refresh paths (lines 1140/1173) still passed provider404s. Looks like a previous half-finished cleanup — the fix was applied to one branch of the code path but not propagated to the symmetric branch.

Related

Issue Silo-Server/silo-plugin-tmdb#2 — symptom report. The TMDB plugin itself is fine; the bug is in silo-server's classification of child-resource 404s.

Suggested follow-up (out of scope for this PR)

The asymmetry between processInternal (~lines 870-1240) and fetchTargetSeasonResults / fetchTargetEpisodeResults (~lines 2280-2350) means the same child-fetch logic exists in two places that have drifted apart once already. Worth either (a) consolidating into a shared helper, or (b) making handleProvider404's "should I record this as stale" signal explicit instead of a load-bearing nil-check on provider404s. Both would prevent this class of bug.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Improved metadata handling when seasons and episodes cannot be fetched from certain providers, preventing incorrect stale data from being recorded or propagated.
  • Documentation

    • Added a "Join the community" call-to-action linking to Discord near the top of the README.

…provider IDs

The main-refresh path in MetadataService.processInternal passes
`provider404s` to handleProvider404 for season (line 1140) and episode
(line 1173) fetch errors. handleProvider404 records the item's provider
ID as stale whenever provider404s is non-nil. A 404 fetching seasons or
episodes is a child-resource failure (e.g. TMDB returns 404 for
`/tv/{id}/season/0` when a series has no specials season) — it must not
mark the item's TMDB ID itself as stale.

The equivalent target-refresh paths (fetchTargetSeasonResults at line
2305 and fetchTargetEpisodeResults at line 2339) already pass `nil` for
this exact reason. The main-refresh path was the missing half of that
fix.

In our deployment this bug caused 13,524 series items to have their
`media_items.tmdb_id` cleared and recorded as stale during a single
refresh sweep — every series whose TMDB entry doesn't have a 'specials'
season was affected. Once recorded, `suppressRecordedStaleProviderIDs`
locked the items out of future TMDB enrichment.

Tested by curl-ing 5 affected items against TMDB directly:
- /tv/{id} returns 200 for all 5
- /season/1 returns 200 for all 5
- /season/0 returns 404 for 4 of 5 (the ones that don't have specials)

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Jun 1, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 94a850f4-0e68-4626-a87b-5b8b7f8a490f

📥 Commits

Reviewing files that changed from the base of the PR and between 14c12f9 and 4885aa0.

📒 Files selected for processing (1)
  • README.md
✅ Files skipped from review due to trivial changes (1)
  • README.md

📝 Walkthrough

Walkthrough

HTTP 404 errors encountered during metadata season and episode fetching are now treated as child-resource normal failures rather than propagating as item-level stale provider IDs. The handleProvider404 calls in Phase 4a and Phase 4b now receive nil for the provider404s accumulator, preventing external ID recording while preserving existing retry and skip behavior. The README adds a “Join the community on Discord” link near the top.

Changes

Child-resource 404 error handling

Layer / File(s) Summary
Phase 4a/4b child-resource 404 handling
internal/metadata/service.go
In both season fetching (Phase 4a) and episode fetching (Phase 4b), handleProvider404 is called with provider404s set to nil, preventing 404-derived external IDs from propagating as item-level stale provider IDs while maintaining retry and skip behavior.

Docs: README community link

Layer / File(s) Summary
Add Discord invite CTA
README.md
Added a “Join the community on Discord” call-to-action with an invite link near the beginning of the README.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Poem

🐰 When seasons and episodes return a hollow four-o-four,
I nibble the nil and mark the child not the door,
Parent stays calm, its IDs remain pure,
A hop, a patch — metadata's secure,
Join the garden chat, come share and explore! 🎧

🚥 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 accurately captures the main bug fix: preventing 404 errors from season/episode child-resource fetches from being incorrectly promoted to item-level stale provider IDs.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@Quick104

Quick104 commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

🤖 Generated with Claude Code

@Quick104
Quick104 merged commit 06a1cf3 into Silo-Server:main Jun 6, 2026
1 check passed
Quick104 added a commit to thezak48/silo-server that referenced this pull request Jun 7, 2026
…provider IDs (Silo-Server#35)

* fix(metadata): don't promote season/episode 404s to item-level stale provider IDs

The main-refresh path in MetadataService.processInternal passes
`provider404s` to handleProvider404 for season (line 1140) and episode
(line 1173) fetch errors. handleProvider404 records the item's provider
ID as stale whenever provider404s is non-nil. A 404 fetching seasons or
episodes is a child-resource failure (e.g. TMDB returns 404 for
`/tv/{id}/season/0` when a series has no specials season) — it must not
mark the item's TMDB ID itself as stale.

The equivalent target-refresh paths (fetchTargetSeasonResults at line
2305 and fetchTargetEpisodeResults at line 2339) already pass `nil` for
this exact reason. The main-refresh path was the missing half of that
fix.

In our deployment this bug caused 13,524 series items to have their
`media_items.tmdb_id` cleared and recorded as stale during a single
refresh sweep — every series whose TMDB entry doesn't have a 'specials'
season was affected. Once recorded, `suppressRecordedStaleProviderIDs`
locked the items out of future TMDB enrichment.

Tested by curl-ing 5 affected items against TMDB directly:
- /tv/{id} returns 200 for all 5
- /season/1 returns 200 for all 5
- /season/0 returns 404 for 4 of 5 (the ones that don't have specials)

---------

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Co-authored-by: Quick <[email protected]>
@fluxis
fluxis deleted the fix/season-404-not-item-stale branch June 9, 2026 17:32
Quick104 added a commit that referenced this pull request Jun 11, 2026
…provider IDs (#35)

* fix(metadata): don't promote season/episode 404s to item-level stale provider IDs

The main-refresh path in MetadataService.processInternal passes
`provider404s` to handleProvider404 for season (line 1140) and episode
(line 1173) fetch errors. handleProvider404 records the item's provider
ID as stale whenever provider404s is non-nil. A 404 fetching seasons or
episodes is a child-resource failure (e.g. TMDB returns 404 for
`/tv/{id}/season/0` when a series has no specials season) — it must not
mark the item's TMDB ID itself as stale.

The equivalent target-refresh paths (fetchTargetSeasonResults at line
2305 and fetchTargetEpisodeResults at line 2339) already pass `nil` for
this exact reason. The main-refresh path was the missing half of that
fix.

In our deployment this bug caused 13,524 series items to have their
`media_items.tmdb_id` cleared and recorded as stale during a single
refresh sweep — every series whose TMDB entry doesn't have a 'specials'
season was affected. Once recorded, `suppressRecordedStaleProviderIDs`
locked the items out of future TMDB enrichment.

Tested by curl-ing 5 affected items against TMDB directly:
- /tv/{id} returns 200 for all 5
- /season/1 returns 200 for all 5
- /season/0 returns 404 for 4 of 5 (the ones that don't have specials)

---------

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Co-authored-by: Quick <[email protected]>
Quick104 added a commit that referenced this pull request Jun 17, 2026
…provider IDs (#35)

* fix(metadata): don't promote season/episode 404s to item-level stale provider IDs

The main-refresh path in MetadataService.processInternal passes
`provider404s` to handleProvider404 for season (line 1140) and episode
(line 1173) fetch errors. handleProvider404 records the item's provider
ID as stale whenever provider404s is non-nil. A 404 fetching seasons or
episodes is a child-resource failure (e.g. TMDB returns 404 for
`/tv/{id}/season/0` when a series has no specials season) — it must not
mark the item's TMDB ID itself as stale.

The equivalent target-refresh paths (fetchTargetSeasonResults at line
2305 and fetchTargetEpisodeResults at line 2339) already pass `nil` for
this exact reason. The main-refresh path was the missing half of that
fix.

In our deployment this bug caused 13,524 series items to have their
`media_items.tmdb_id` cleared and recorded as stale during a single
refresh sweep — every series whose TMDB entry doesn't have a 'specials'
season was affected. Once recorded, `suppressRecordedStaleProviderIDs`
locked the items out of future TMDB enrichment.

Tested by curl-ing 5 affected items against TMDB directly:
- /tv/{id} returns 200 for all 5
- /season/1 returns 200 for all 5
- /season/0 returns 404 for 4 of 5 (the ones that don't have specials)

---------

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Co-authored-by: Quick <[email protected]>
Quick104 added a commit that referenced this pull request Jun 17, 2026
…provider IDs (#35)

* fix(metadata): don't promote season/episode 404s to item-level stale provider IDs

The main-refresh path in MetadataService.processInternal passes
`provider404s` to handleProvider404 for season (line 1140) and episode
(line 1173) fetch errors. handleProvider404 records the item's provider
ID as stale whenever provider404s is non-nil. A 404 fetching seasons or
episodes is a child-resource failure (e.g. TMDB returns 404 for
`/tv/{id}/season/0` when a series has no specials season) — it must not
mark the item's TMDB ID itself as stale.

The equivalent target-refresh paths (fetchTargetSeasonResults at line
2305 and fetchTargetEpisodeResults at line 2339) already pass `nil` for
this exact reason. The main-refresh path was the missing half of that
fix.

In our deployment this bug caused 13,524 series items to have their
`media_items.tmdb_id` cleared and recorded as stale during a single
refresh sweep — every series whose TMDB entry doesn't have a 'specials'
season was affected. Once recorded, `suppressRecordedStaleProviderIDs`
locked the items out of future TMDB enrichment.

Tested by curl-ing 5 affected items against TMDB directly:
- /tv/{id} returns 200 for all 5
- /season/1 returns 200 for all 5
- /season/0 returns 404 for 4 of 5 (the ones that don't have specials)

---------

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Co-authored-by: Quick <[email protected]>
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.

2 participants