Repository navigation
fix(naming,metadata): anchor identity on provider IDs, drop bare-numeric IDs, back off match queue retries - #112
Conversation
…ric IDs, back off match queue retries
Three scanner/matching fixes validated against dev data:
- Group identity: explicit structured provider tags ({tmdb-...},
[tvdbid-...]) now anchor a group's identity, so folder/file title
conflicts (renamed releases in Radarr-tagged folders) no longer mark
groups ambiguous and silently exclude them from matching. 3,049 of
3,121 ambiguous groups on dev carried explicit tags.
- ParseFolderIDs: remove bare trailing numeric ID parsing entirely,
mirroring Jellyfin's path-attribute model (bracketed key tags plus
unambiguous tt-prefixed IMDb ids only). Titles ending in numbers
("District 9", "Beverly Hills 90210", "Season 01") were misparsed as
trusted IDs, which suppresses title search and silently mismatches.
The folderType parameter existed only to type bare numerics, so it
is gone too.
- Match queues: replace the constant 15s/30s retry delay with shared
exponential backoff capped at 24h. Terminal failures ("no metadata
found from any provider") had rows at 15k+ attempts hot-looping
every 15s on dev.
Co-Authored-By: Claude Fable 5 <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughTightens folder ID parsing to only accept explicit structured provider tags and IMDb tt IDs, removes the folderType argument from ParseFolderIDs call sites, threads an idAnchored flag into group identity resolution, and caps match-queue retry backoff with a capped exponential SQL expression. ChangesFolder ID parsing tightening and identity resolution
Match queue retry backoff capping
🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly Related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
internal/naming/folderid.go (1)
58-65:⚠️ Potential issue | 🟠 Major | ⚡ Quick winMerge trailing bare IMDb IDs with structured tags.
Line 59 returns as soon as any structured tag is found, so
ParseFolderIDs("Some Show [tvdbid-81189] tt1375666")yields onlyTvdbID. That drops explicit IMDb evidence and weakens the provider-ID anchor downstream.Proposed fix
func ParseFolderIDs(folderName string) *FolderIDHints { - if hints := ParseStructuredFolderIDs(folderName); hints != nil { - return hints - } + hints := ParseStructuredFolderIDs(folderName) trimmed := strings.TrimSpace(folderName) if m := trailingImdbIDPattern.FindStringSubmatch(trimmed); m != nil { - return &FolderIDHints{ImdbID: strings.ToLower(m[1])} + if hints == nil { + hints = &FolderIDHints{} + } + if hints.ImdbID == "" { + hints.ImdbID = strings.ToLower(m[1]) + } } - return nil + if hints == nil || (hints.TmdbID == "" && hints.ImdbID == "" && hints.TvdbID == "") { + return nil + } + return hints }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/naming/folderid.go` around lines 58 - 65, ParseFolderIDs currently returns immediately if ParseStructuredFolderIDs finds any structured tag, which prevents merging a trailing bare IMDb ID (matched by trailingImdbIDPattern) into the returned FolderIDHints; update ParseFolderIDs so that after calling ParseStructuredFolderIDs it still checks trailingImdbIDPattern on the trimmed folderName and, if a match exists, sets/overwrites hints.ImdbID = strings.ToLower(m[1]) before returning the hints (preserve existing behavior for other fields). Reference: ParseFolderIDs, ParseStructuredFolderIDs, trailingImdbIDPattern, and FolderIDHints.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/naming/folderid_numeric_test.go`:
- Around line 35-51: Update the test TestParseFolderIDs_StructuredTagsStillParse
to include a mixed case like `Some Show (2010) [tvdbid-81189] tt1375666` that
asserts ParseFolderIDs returns both TvdbID=="81189" and ImdbID=="tt1375666";
this will lock in the intended merge behavior and catch the early-return bug in
ParseFolderIDs by ensuring it does not stop parsing after seeing a structured
tag.
---
Outside diff comments:
In `@internal/naming/folderid.go`:
- Around line 58-65: ParseFolderIDs currently returns immediately if
ParseStructuredFolderIDs finds any structured tag, which prevents merging a
trailing bare IMDb ID (matched by trailingImdbIDPattern) into the returned
FolderIDHints; update ParseFolderIDs so that after calling
ParseStructuredFolderIDs it still checks trailingImdbIDPattern on the trimmed
folderName and, if a match exists, sets/overwrites hints.ImdbID =
strings.ToLower(m[1]) before returning the hints (preserve existing behavior for
other fields). Reference: ParseFolderIDs, ParseStructuredFolderIDs,
trailingImdbIDPattern, and FolderIDHints.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 2a7c50e0-ae56-4ad7-a2d6-4af435537f3d
📒 Files selected for processing (11)
internal/metadata/movie_match_queue_repo.gointernal/metadata/series_root_match_queue_repo.gointernal/metadata/service.gointernal/naming/folderid.gointernal/naming/folderid_numeric_test.gointernal/naming/folderid_test.gointernal/naming/group_identity.gointernal/naming/group_identity_test.gointernal/naming/movie_identity.gointernal/naming/root_inference.gointernal/scanner/root_observation.go
ParseFolderIDs returned early on any structured tag, so a folder like "Show [tvdbid-81189] tt1375666" lost the trailing IMDb id. Parse both and merge, with an explicit structured imdb tag still taking precedence over a trailing bare id. Matches Jellyfin, which resolves each provider key independently. Co-Authored-By: Claude Fable 5 <[email protected]>
…ric IDs, back off match queue retries (#112) * fix(naming,metadata): anchor identity on provider IDs, drop bare-numeric IDs, back off match queue retries Three scanner/matching fixes validated against dev data: - Group identity: explicit structured provider tags ({tmdb-...}, [tvdbid-...]) now anchor a group's identity, so folder/file title conflicts (renamed releases in Radarr-tagged folders) no longer mark groups ambiguous and silently exclude them from matching. 3,049 of 3,121 ambiguous groups on dev carried explicit tags. - ParseFolderIDs: remove bare trailing numeric ID parsing entirely, mirroring Jellyfin's path-attribute model (bracketed key tags plus unambiguous tt-prefixed IMDb ids only). Titles ending in numbers ("District 9", "Beverly Hills 90210", "Season 01") were misparsed as trusted IDs, which suppresses title search and silently mismatches. The folderType parameter existed only to type bare numerics, so it is gone too. - Match queues: replace the constant 15s/30s retry delay with shared exponential backoff capped at 24h. Terminal failures ("no metadata found from any provider") had rows at 15k+ attempts hot-looping every 15s on dev. Co-Authored-By: Claude Fable 5 <[email protected]> * fix(naming): merge trailing bare IMDb id with structured folder tags ParseFolderIDs returned early on any structured tag, so a folder like "Show [tvdbid-81189] tt1375666" lost the trailing IMDb id. Parse both and merge, with an explicit structured imdb tag still taking precedence over a trailing bare id. Matches Jellyfin, which resolves each provider key independently. Co-Authored-By: Claude Fable 5 <[email protected]> --------- Co-authored-by: Claude Fable 5 <[email protected]>
…ric IDs, back off match queue retries (#112) * fix(naming,metadata): anchor identity on provider IDs, drop bare-numeric IDs, back off match queue retries Three scanner/matching fixes validated against dev data: - Group identity: explicit structured provider tags ({tmdb-...}, [tvdbid-...]) now anchor a group's identity, so folder/file title conflicts (renamed releases in Radarr-tagged folders) no longer mark groups ambiguous and silently exclude them from matching. 3,049 of 3,121 ambiguous groups on dev carried explicit tags. - ParseFolderIDs: remove bare trailing numeric ID parsing entirely, mirroring Jellyfin's path-attribute model (bracketed key tags plus unambiguous tt-prefixed IMDb ids only). Titles ending in numbers ("District 9", "Beverly Hills 90210", "Season 01") were misparsed as trusted IDs, which suppresses title search and silently mismatches. The folderType parameter existed only to type bare numerics, so it is gone too. - Match queues: replace the constant 15s/30s retry delay with shared exponential backoff capped at 24h. Terminal failures ("no metadata found from any provider") had rows at 15k+ attempts hot-looping every 15s on dev. Co-Authored-By: Claude Fable 5 <[email protected]> * fix(naming): merge trailing bare IMDb id with structured folder tags ParseFolderIDs returned early on any structured tag, so a folder like "Show [tvdbid-81189] tt1375666" lost the trailing IMDb id. Parse both and merge, with an explicit structured imdb tag still taking precedence over a trailing bare id. Matches Jellyfin, which resolves each provider key independently. Co-Authored-By: Claude Fable 5 <[email protected]> --------- Co-authored-by: Claude Fable 5 <[email protected]>
Problem
A review of the scanner → matching → metadata pipeline (validated against the dev database) found three issues that silently break or degrade matching:
Title conflicts overrode explicit provider IDs. When a Radarr-tagged folder contains a renamed release (folder
Override (2021) {tmdb-694938}, fileR.I.A. (2021).mkv), group inference marked the groupambiguousvia the title-coherence check — even though the structured tag resolves identity unambiguously. Ambiguous groups are skipped by the matcher entirely. On dev, 3,049 of 3,121 ambiguous groups carried explicit provider tags.Bare trailing numbers were parsed as provider IDs.
ParseFolderIDstreated any trailing number in a year-less folder name as a TMDB/TVDB ID ("District 9" →tmdb=9, and on dev:Season 01→tmdb_id="01"). Misparsed IDs become trusted match hints, which suppress title/year search and filter out all correct results — silent wrong match or permanent no-match. This heuristic already needed one emergency patch (534f7bb) and still failed on real titles ("Beverly Hills 90210").Match queues hot-looped terminal failures. "No metadata found from any provider" was retried at a constant 15s/30s forever. Dev had 1,580 queue rows in error state with attempt counts up to 15,841 (~66 hours of continuous provider hammering per item).
Approach
{tmdb-…},[tvdbid-…]) on the observed root or filename now anchor identity; all five ambiguity paths are gated on the anchor. Evidence still records the conflict (…_resolved_by_provider_ids) for diagnostics. Bare numerics deliberately do not anchor.ParseFolderIDs: bare trailing numeric parsing removed entirely, mirroring Jellyfin's path-attribute model (PathExtensions.GetAttributeValue: bracketed key tags only, plus unambiguous tt-prefixed IMDb ids). ThefolderTypeparameter existed only to type bare numerics, so it is dropped, which also collapses theParseFolderIDs(name, "movie") || ParseFolderIDs(name, "series")double-call patterns at four sites.matchQueueBackoffExprreplaces the constant retry delay in both queues'UpdateError:base × 2^attempt_count, exponent clamped at 16, capped at 24h. Rows still self-heal (deleted on first success), so no new terminal state or admin surface is needed.Validation
Deployed to dev and verified live:
Override {tmdb-694938}/On Fire {tmdb-1196791}flipped toresolvedon rescan and matched the correct movies via their tags.Season 01(tmdb_id="01") group is gone after rescan; files re-inferred cleanly.Risks / follow-up
filename.govsroot_inference.goparsing stacks ininternal/naming.AI use
Authored by Claude Code (Fable 5) under human direction; findings and fixes validated against the dev environment as described above.
🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Tests