Skip to content

fix(metadata): harden provider decoding and refresh lifecycle - #318

Merged
ReenigneArcher merged 43 commits into
masterfrom
codex/fix-metadata-agents
Oct 17, 2026
Merged

ReenigneArcher merged 43 commits into
masterfrom
codex/fix-metadata-agents

Conversation

@ReenigneArcher

Copy link
Copy Markdown
Member

Description

Metadata refreshes could reject valid provider responses, leave TV libraries partially matched, and display stale metadata, artwork, or progress after a refresh or rematch. This change makes provider decoding explicit and carries refresh state through movies, shows, seasons, episodes, and translations.

  • Replace guessed response keys with endpoint-specific TMDB, TheTVDB, ThemerrDB, and TrailerDB models. Handle TVDB movie, season, episode, and translation payloads without the incompatible generated company models.
  • Correct Unicode title matching, empty TVDB search fallback, default season ordering, localized text fallback, and the distinction between TVDB popularity and ratings.
  • Bound provider requests, honor response cache expiry and clearing, bypass caches for refresh work, invalidate TVDB tokens when credentials change, and back off failed refreshes without starving later items.
  • Clear old metadata immediately on unlink/rematch while keeping replacement fetches queued. Preserve catalog files and playback history, reject obsolete database writes, and discard superseded browser polls.
  • Save matched show metadata before descendant discovery, recover every pending translation after restart, and register automatic season/episode work so loaders, progress, and failure counts reflect the actual queue.
  • Validate artwork and publish downloads atomically, retain working images on replacement failures, and prevent overlapping requests from deleting shared covers. Preserve secondary extras on provider errors and clear them on confirmed misses or rematches.
  • Add administrator unlink controls and consistent metadata status badges on cards and detail covers. Update known issues and the roadmap, and fix the two existing test Clippy warnings.

URL-specific artwork files are retained because other links or in-flight work may still use them. Reference-aware cleanup is tracked as follow-up maintenance work.

Screenshot

Issues Fixed or Closed

Roadmap Issues

Testing

Added or updated provider contract fixtures and regressions for locale state, cache behavior, unlink/rematch, overlapping artwork requests, out-of-order browser polls, restart recovery, and nested refresh progress. The artwork, polling, and pending-locale defects were reproduced before their fixes.

Local Windows validation passed with KOKO_SKIP_FFMPEG_DOWNLOAD=1, KOKO_SECRET_STORE=sample, and the UCRT64 runtime on PATH:

  • cargo test -p koko --no-default-features -j 1 --lib: 75 passed.
  • cargo test -p koko --no-default-features -j 1 --test main --test metadata_regressions: 169 integration tests and 13 metadata regressions passed.
  • cargo clippy -p koko --no-default-features --all-targets -j 1 -- -D warnings: passed.
  • cargo +nightly fmt --all -- --check: passed.
  • In crates/client-web: npm run check, npm test (155 passed), and npm run build: passed.
  • Branch diff whitespace and documentation link checks: passed.

Packaged platform builds and browser end-to-end tests were not run locally. Hosted CI results are separate from these local checks.

Type of Change

  • feat: New feature (non-breaking change which adds functionality)
  • fix: Bug fix (non-breaking change which fixes an issue)
  • docs: Documentation only changes
  • style: Changes that do not affect the meaning of the code (white-space, formatting, missing semicolons, etc.)
  • refactor: Code change that neither fixes a bug nor adds a feature
  • perf: Code change that improves performance
  • test: Adding missing tests or correcting existing tests
  • build: Changes that affect the build system or external dependencies
  • ci: Changes to CI configuration files and scripts
  • chore: Other changes that don't modify src or test files
  • revert: Reverts a previous commit
  • BREAKING CHANGE: Introduces a breaking change (can be combined with any type above)

Checklist

  • Code follows the style guidelines of this project
  • Code has been self-reviewed
  • Code has been commented, particularly in hard-to-understand areas
  • Code docstring/documentation-blocks for new or existing methods/components have been added or updated
  • Tests have been added or updated for new or modified functionality, including regression tests for bug fixes

AI Usage

See our AI usage policy.

  • AI tools were used while preparing this PR

Reset metadata for the item and its descendants before queueing replacement data. Add an administrator unlink endpoint that suppresses automatic matching until an explicit rematch.

Invalidate obsolete queued and running metadata writes, and release affected activity ownership while preserving the rest of a library refresh.
Add Unlink metadata alongside item refresh controls. Refresh the visible item and invalidate browse caches immediately after unlinking or rematching, including during theme playback.

Keep mock rematches queued and reject obsolete refresh completions. Cover immediate clearing, descendant cards, pending unlink controls, and viewer permissions.
TheTVDB can return no results for a full official title while finding the same record without standalone the words. Retry empty searches once with those articles removed for both manual and automatic matching.

Preserve successful search results, original matching scores, provider errors, and existing response decoding. Add regressions for the reported 2021 series, bounded retries, Unicode, and unchanged successful searches.
@ReenigneArcher
ReenigneArcher force-pushed the codex/fix-metadata-agents branch from 7d1b87b to 88f3a6f Compare October 17, 2026 16:51
@sonarqubecloud

Copy link
Copy Markdown

@codecov

codecov Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 72.08122% with 385 lines in your changes missing coverage. Please review.
✅ Project coverage is 61.03%. Comparing base (76a4a0d) to head (eb65030).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
crates/server/src/web/routes/media.rs 44.13% 281 Missing ⚠️
...tes/server/src/metadata/providers/tvdb/response.rs 85.30% 41 Missing ⚠️
crates/server/src/metadata/mod.rs 91.64% 31 Missing ⚠️
crates/server/src/metadata/providers/tmdb.rs 73.75% 21 Missing ⚠️
crates/server/src/metadata/providers/themerr.rs 63.63% 4 Missing ⚠️
crates/server/src/metadata/providers/trailerdb.rs 94.11% 3 Missing ⚠️
crates/server/src/web/routes/metadata_jobs.rs 92.68% 3 Missing ⚠️
crates/server/src/metadata/cache_policy.rs 90.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #318      +/-   ##
==========================================
+ Coverage   54.63%   61.03%   +6.39%     
==========================================
  Files          40       45       +5     
  Lines       13396    13237     -159     
==========================================
+ Hits         7319     8079     +760     
+ Misses       6077     5158     -919     
Flag Coverage Δ
aarch64-apple-darwin 60.03% <72.08%> (+6.26%) ⬆️
aarch64-unknown-linux-gnu 60.03% <72.08%> (+6.26%) ⬆️
aarch64-unknown-linux-musl 60.57% <72.08%> (+6.33%) ⬆️
x86_64-apple-darwin 60.03% <72.08%> (+6.26%) ⬆️
x86_64-pc-windows-msvc 61.09% <72.08%> (+6.41%) ⬆️
x86_64-unknown-linux-gnu 60.03% <72.08%> (+6.25%) ⬆️
x86_64-unknown-linux-musl 60.57% <72.08%> (+6.33%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
crates/server/src/media.rs 83.37% <100.00%> (+0.66%) ⬆️
crates/server/src/metadata/artwork.rs 100.00% <100.00%> (ø)
crates/server/src/metadata/http.rs 100.00% <100.00%> (ø)
crates/server/src/metadata/providers/tvdb.rs 18.99% <ø> (-24.47%) ⬇️
crates/server/src/web/routes/mod.rs 100.00% <ø> (ø)
crates/server/src/metadata/cache_policy.rs 90.00% <90.00%> (ø)
crates/server/src/metadata/providers/trailerdb.rs 81.91% <94.11%> (-1.42%) ⬇️
crates/server/src/web/routes/metadata_jobs.rs 92.68% <92.68%> (ø)
crates/server/src/metadata/providers/themerr.rs 45.34% <63.63%> (+6.40%) ⬆️
crates/server/src/metadata/providers/tmdb.rs 33.50% <73.75%> (+4.25%) ⬆️
... and 3 more

... and 5 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 76a4a0d...eb65030. Read the comment docs.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ReenigneArcher
ReenigneArcher merged commit 87a2f8a into master Oct 17, 2026
74 of 75 checks passed
@ReenigneArcher
ReenigneArcher deleted the codex/fix-metadata-agents branch October 17, 2026 18:58
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