Repository navigation
Fix ebook match dialog to support generic provider IDs - #182
Conversation
|
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 (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds end-to-end support for matching non-video items using arbitrary provider IDs. The metadata service gains a ChangesGeneric Provider ID Matching
🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 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.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2886335283
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| func normalizeMatchProviderIDs(input map[string]string) map[string]string { | ||
| out := make(map[string]string, len(input)) | ||
| for provider, providerID := range input { | ||
| setMatchProviderID(out, provider, providerID) | ||
| } | ||
| return out | ||
| } |
There was a problem hiding this comment.
Normalize provider IDs before applying matches
The new normalization helper is used only by the search endpoint; apply still passes req.ProviderIDs directly into Process. If a generic candidate or API client supplies a key such as ISBN or ISBN, prepareProcessRequest treats it as distinct from an existing lowercase isbn ID and can merge the stale value back into the request, causing providers to resolve the old match or return no metadata. Normalize the apply map as well, and reject it if no nonblank entries remain.
Useful? React with 👍 / 👎.
| // Search uses the item-level chain. Video child records search through the | ||
| // series chain; non-video content searches through its own content level. | ||
| contentLevel := providerChainContentLevel(query.ContentType) |
There was a problem hiding this comment.
Deduplicate candidates by generic provider IDs
Routing ebook, audiobook, and manga searches through their own chains sends their results into NormalizeCandidates, but that function's identity logic in internal/metadata/match_candidates.go only considers TMDB/TVDB/IMDb and metadb. Consequently, two results carrying the same isbn, openlibrary, or another generic ID receive separate synthetic keys instead of being merged, so the dialog shows duplicate matches and loses cross-provider IDs/agreement. Extend candidate normalization to fingerprint arbitrary durable provider IDs as part of this routing change.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@web/src/components/MatchItemDialog.tsx`:
- Around line 93-100: The handleSearch function uses parseInt(year, 10) without
validation, which can result in NaN being serialized to null in the request
object. Add a guard condition to validate that the year value is actually a
valid numeric string before parsing it. Check that parseInt returns a valid
number (not NaN) and only include the year in the ItemMatchSearchRequest if it
parses successfully; otherwise leave it as undefined like the title field
handling.
🪄 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: 883ad61a-de76-4fde-a446-ddb896492c26
📒 Files selected for processing (9)
internal/api/handlers/admin_match.gointernal/api/handlers/admin_match_test.gointernal/metadata/service.gointernal/metadata/service_content_level_test.gointernal/metadata/types.goweb/src/api/types.tsweb/src/components/MatchItemDialog.tsxweb/src/hooks/queries/items.tsweb/src/pages/AdminLibraries.tsx
…'t be bypassed by casing Review on PR Silo-Server#276 flagged that suppressRecordedStaleProviderIDs lowercases and trims the stored stale row's provider before looking it up in the incoming map, while the map keys are used verbatim, and that HandleApplyItemMatch passes req.ProviderIDs from the JSON body straight into metadata.Process without the normalization the search endpoint applies. A caller-supplied key like "TMDB" or " tmdb " therefore defeated the suppression. The same normalization gap was previously flagged on PR Silo-Server#182. Fix both layers: - HandleApplyItemMatch now runs req.ProviderIDs through normalizeMatchProviderIDs (same semantics as the search endpoint) and returns 400 when no non-blank entries remain, mirroring the existing empty-map rejection. - suppressRecordedStaleProviderIDs now indexes the incoming map by normalized key and deletes the matching original keys, so suppression is robust regardless of caller casing or padding. Adds regression tests at both layers: a metadata-level case where the durable row arrives as "TMDB " while the stale row records "tmdb", and handler-level cases asserting apply normalizes keys/values and rejects all-blank provider-id maps. Co-Authored-By: Claude Fable 5 <[email protected]>
…Ds (#276) * fix(metadata): stop manual rematch from resurrecting recorded stale IDs The Apply Match flow (ModeIdentify) re-injected durable provider IDs into the identify request without checking stale_media_ids, so a known-dead tmdb ID rode along, 404ed again during the Phase-2 fetch, and was re-recorded with a fresh last_seen_at — the item never left the Stale External IDs list and jumped back to the top after every rematch. Filter recorded-stale IDs out of the injected durable set in prepareProcessRequest. Caller-supplied IDs are untouched, so an admin deliberately re-selecting a previously-stale ID still retries it (which is also why the ModeIdentify suppression guard in processInternal stays). Fixes #268 Co-Authored-By: Claude Fable 5 <[email protected]> * fix(metadata): normalize provider-id keys so stale-ID suppression can't be bypassed by casing Review on PR #276 flagged that suppressRecordedStaleProviderIDs lowercases and trims the stored stale row's provider before looking it up in the incoming map, while the map keys are used verbatim, and that HandleApplyItemMatch passes req.ProviderIDs from the JSON body straight into metadata.Process without the normalization the search endpoint applies. A caller-supplied key like "TMDB" or " tmdb " therefore defeated the suppression. The same normalization gap was previously flagged on PR #182. Fix both layers: - HandleApplyItemMatch now runs req.ProviderIDs through normalizeMatchProviderIDs (same semantics as the search endpoint) and returns 400 when no non-blank entries remain, mirroring the existing empty-map rejection. - suppressRecordedStaleProviderIDs now indexes the incoming map by normalized key and deletes the matching original keys, so suppression is robust regardless of caller casing or padding. Adds regression tests at both layers: a metadata-level case where the durable row arrives as "TMDB " while the stale row records "tmdb", and handler-level cases asserting apply normalizes keys/values and rejects all-blank provider-id maps. Co-Authored-By: Claude Fable 5 <[email protected]> --------- Co-authored-by: Claude Fable 5 <[email protected]> Co-authored-by: Quick <[email protected]>
* fix(metadata): match non-video items with content-aware providers * fix(web): guard invalid match year parsing
…Ds (Silo-Server#276) * fix(metadata): stop manual rematch from resurrecting recorded stale IDs The Apply Match flow (ModeIdentify) re-injected durable provider IDs into the identify request without checking stale_media_ids, so a known-dead tmdb ID rode along, 404ed again during the Phase-2 fetch, and was re-recorded with a fresh last_seen_at — the item never left the Stale External IDs list and jumped back to the top after every rematch. Filter recorded-stale IDs out of the injected durable set in prepareProcessRequest. Caller-supplied IDs are untouched, so an admin deliberately re-selecting a previously-stale ID still retries it (which is also why the ModeIdentify suppression guard in processInternal stays). Fixes Silo-Server#268 Co-Authored-By: Claude Fable 5 <[email protected]> * fix(metadata): normalize provider-id keys so stale-ID suppression can't be bypassed by casing Review on PR Silo-Server#276 flagged that suppressRecordedStaleProviderIDs lowercases and trims the stored stale row's provider before looking it up in the incoming map, while the map keys are used verbatim, and that HandleApplyItemMatch passes req.ProviderIDs from the JSON body straight into metadata.Process without the normalization the search endpoint applies. A caller-supplied key like "TMDB" or " tmdb " therefore defeated the suppression. The same normalization gap was previously flagged on PR Silo-Server#182. Fix both layers: - HandleApplyItemMatch now runs req.ProviderIDs through normalizeMatchProviderIDs (same semantics as the search endpoint) and returns 400 when no non-blank entries remain, mirroring the existing empty-map rejection. - suppressRecordedStaleProviderIDs now indexes the incoming map by normalized key and deletes the matching original keys, so suppression is robust regardless of caller casing or padding. Adds regression tests at both layers: a metadata-level case where the durable row arrives as "TMDB " while the stale row records "tmdb", and handler-level cases asserting apply normalizes keys/values and rejects all-blank provider-id maps. Co-Authored-By: Claude Fable 5 <[email protected]> --------- Co-authored-by: Claude Fable 5 <[email protected]> Co-authored-by: Quick <[email protected]>
Fixes #180
Summary
Testing
go test ./internal/api/handlers -run AdminMatch -count=1go test ./internal/metadata -run ProviderChainContentLevel -count=1pnpm exec tsc -bpnpm exec prettier --check web/src/components/MatchItemDialog.tsx web/src/hooks/queries/items.ts web/src/pages/AdminLibraries.tsx web/src/api/types.tspnpm exec eslint web/src/components/MatchItemDialog.tsx web/src/pages/AdminLibraries.tsx(exited 0 with one pre-existing warning)git diff --check origin/main..HEADReview
Residual Risk
AI Assistance
Summary by CodeRabbit