Repository navigation
feat(downloads): include the series poster in episode download manifests - #1746
Conversation
An episode's poster is its still, so offline clients had no series poster for series-level screens and showed a cropped still or a blurred placeholder instead. v2 episode manifests now carry series_poster_thumbhash and artwork_urls.series_poster, and the artwork proxy serves the new series_poster kind after checking access to the parent series. The frozen v1 manifest is unchanged.
… route The v1 and v2 artwork routes share ServeArtwork, so the new v2-only series_poster kind was also served on /api/v1. The v1 handler now answers it with 404, as it does any unknown kind.
Code Review Could Not Complete
|
| Options | Enabled |
|---|---|
| Bug | ✅ |
| Performance | ✅ |
| Security | ✅ |
| Business Logic | ❌ |
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
📒 Files selected for processing (10)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
The Suggested fix: Automated check: Macroscope check run agent (gpt-6-luna). No validation was performed. Posted via Macroscope — v1 validation impact |
|
Updated the line to |
|
@kody start-review |
Code Review Completed! 🔥The code review was successfully completed based on your current configurations. Kody Guide: Usage and ConfigurationInteracting with Kody
Providing Context (Files & MCPs)Add these hints in your PR description (or a comment) to unlock deeper checks:
Current Kody ConfigurationReview OptionsThe following review options are enabled or disabled:
|
Quick104
left a comment
There was a problem hiding this comment.
Code review of 93cc6f0: no blocking issues. The v2 additions are additive, the v1 manifest JSON is unchanged, and access to the series is checked before its poster is served. Inline comments, in order of severity:
- Medium: a transient series lookup error silently drops the series poster from the manifest.
- Low: the v1
series_posterguard runs before authorization, its comment doesn't match the code, and a denylist won't catch the next v2-only kind. - Low (performance): two full detail builds per
series_posterrequest, and per-download URLs mean N fetches of one image per season. - Low (docs): §10 of
docs/downloads-api.mddoesn't mention the series poster. - Cleanup: the per-field
ArtworkURLscopy, the duplicated series rule, and a duplicated test fake.
PR body: "Android does not read them yet" is out of date. Silo-Server/silo-android#432 merged on 2026-10-02 and already saves artwork_urls.series_poster and series_poster_thumbhash (OfflineTrackAssetFetcher.kt), so Android already consumes this contract.
Validation: no passed case on the v1.0 board reaches this diff. Validation tasks: none matches.
AI disclosure: written by claude-opus-5-5 in Claude Code via T3 Code (/silo code-review).
| if detail.LogoURL != "" { | ||
| m.ArtworkURLs.Logo = artworkProxyURL(dl.ID, "logo") | ||
| } | ||
| if seriesDetail != nil { |
There was a problem hiding this comment.
Medium. Needs your call. A transient series lookup error silently removes the series poster from the manifest.
The series lookup at line 211 treats every error as "no series": else if sd, err := b.detail.GetItemDetail(ctx, detail.SeriesID, filter); err == nil. That swallow is older than this PR. Before, it only cost stable_identity its series provider IDs. Now this block also hangs visible artwork on it.
- Trigger: the series lookup fails with a DB timeout or pool exhaustion, and the episode lookup succeeds.
- Impact: the manifest returns 200 without
series_poster_thumbhashorartwork_urls.series_poster, and nothing is logged. Clients refetch a manifest only when the row revision goes up, and the iOS client fetches it once per download, so the downloaded series header stays without a poster. In a batch, only successful lookups are cached, so episodes of one season can disagree. - Repair: treat only
catalog.ErrItemNotFoundas "no series" and return any other error. An episode lookup error already fails the build, and the batch endpoint reports it as a skipped entry the client can retry. Whether a series error should fail the whole manifest is your decision, because it also changes thestable_identitypath.
| if kind == "series_poster" { | ||
| // A v2-only kind; the frozen v1 route answers it like any unknown kind. | ||
| h.writeAssetError(w, "artwork", id, downloads.ErrAssetNotFound) | ||
| return | ||
| } |
There was a problem hiding this comment.
Low. Needs your call. This guard keeps series_poster off the frozen v1 route, but it has two side effects.
- v1 status for this kind changed, and the comment is wrong. The check runs before
ServeArtworkcallsauthorizeManagedAsset. On a revoked download,/api/v1/downloads/{id}/artwork/series_posternow returns 404, while/artwork/foostill returns 409download_inactive. Both returned 409 before this PR. A disabled feature shows the same split (403 vs 404), and so do unconfigured offline assets (503 vs 404). No v1 manifest advertises this kind, so real clients are unlikely to notice. Still, "answers it like any unknown kind" is not what the code does. - A denylist won't catch the next kind. The list of servable kinds lives in the shared
artworkImageURLswitch, which v1 and v2 both call. The v2 OpenAPIkindparameter is a plain string with no enum, and the test checks only this one literal. If someone adds a v2-only kind such asseason_posterto the switch, v1 serves it with a 200 and nothing fails.
Repair: an allowlist of the original v1 kinds closes (2). Like this guard, it answers early, so unknown kinds on an inactive download would also get 404 instead of 409. If you'd rather keep v1's check order exactly, filter the kind inside the service after authorization instead.
| if kind == "series_poster" { | |
| // A v2-only kind; the frozen v1 route answers it like any unknown kind. | |
| h.writeAssetError(w, "artwork", id, downloads.ErrAssetNotFound) | |
| return | |
| } | |
| switch kind { | |
| case "poster", "backdrop", "logo": | |
| default: | |
| // The frozen v1 route serves only its original kinds; anything else, | |
| // including v2-only kinds, answers 404. | |
| h.writeAssetError(w, "artwork", id, downloads.ErrAssetNotFound) | |
| return | |
| } |
| if dl.EpisodeID == "" || detail.SeriesID == "" { | ||
| return "", ErrAssetNotFound | ||
| } | ||
| series, err := s.artworkSource.GetItemDetail(ctx, detail.SeriesID, filter) |
There was a problem hiding this comment.
Low (performance). Needs your call. Each series_poster request builds two full catalog details in a row, and it reads only series.PosterURL from them.
- Trigger: any
series_posterfetch. - Impact: line 141 builds the whole episode detail. That build already loads, localizes, and fetches credits for the series row, then adds files, playback defaults, and presigns. Line 157 then builds the whole series detail: credits, videos, rating sources, extras, files, and presigns. Reading the code, I estimate 10 to 20 queries per build. I didn't measure it. A season of N episodes repeats this N times (see the next comment).
- Repair: check access with
EnsureAccessible(ctx, dl.ContentID, filter), whichServeSubtitlealready uses for episode assets, then read the series poster with a narrow lookup. Skipping the episode build drops two checks: that the episode row still exists, and the presentation-library membership check on the episode ID. Decide whether those matter for a series poster.
| if seriesDetail != nil { | ||
| m.SeriesPosterThumbhash = seriesDetail.PosterThumbhash | ||
| if seriesDetail.PosterURL != "" { | ||
| m.SeriesPosterURL = artworkProxyURL(dl.ID, "series_poster") |
There was a problem hiding this comment.
Low (performance). Needs your call. Because the URL is per download, a season of N episodes gets N different URLs for one image.
- Trigger: a season download or a series monitor sync. The iOS change fetches
series_posteronce per download record. - Impact: for 20 episodes, the server does 20 image-store fetches of the same poster plus 40 detail builds (previous comment). The artwork route has no ETag or 304 path and no server-side singleflight or cache, and distinct URLs mean the client HTTP cache never hits across episodes. The PR's Risks section mentions the extra request per episode, but not the repeated upstream fetch.
- Repair (contract choice): use a URL that is the same for every episode of a series, so clients and caches dedupe it. Or tell clients in
docs/downloads-api.mdto dedupe byseries_id, or coalesce concurrent fetches on the server. The first changes the v2 contract shape, so it's better decided before v2 locks.
| GeneratedAt: NewInstant(generated), | ||
| ArtworkURLs: row.ArtworkURLs, | ||
| } | ||
| out.ArtworkURLs.Poster = row.ArtworkURLs.Poster |
There was a problem hiding this comment.
Cleanup. Copying field by field drops a compile-time check.
ArtworkURLs: row.ArtworkURLs compiled only while the domain struct and the v2 struct had the same fields, so the two couldn't drift apart. With per-field copies, a new field on downloads.OfflineManifest.ArtworkURLs reaches v1, which marshals that struct directly. It also compiles cleanly and is missing from v2 without any error, and the rewrite-guard list at line 184 has to be updated by hand.
Repair: move SeriesPoster into the domain ArtworkURLs struct tagged json:"-" (v1 output stays the same), and convert instead of assign. Plain assignment won't compile because the struct tags differ. A struct conversion ignores tags, so it does compile. I checked both in a scratch program. The pointer list at line 184 remains a manual step either way.
There was a problem hiding this comment.
Done in 87c93ad: SeriesPoster moved into the domain ArtworkURLs struct tagged json:"-", and v2 converts it through a type alias of its anonymous struct, so the OpenAPI schema stays inline and unchanged. The rewrite-guard list is still manual.
| case "logo": | ||
| imageURL = detail.LogoURL | ||
| case "series_poster": | ||
| if dl.EpisodeID == "" || detail.SeriesID == "" { |
There was a problem hiding this comment.
Cleanup. This repeats the series rule from ManifestBuilder.build (manifest.go:205, dl.EpisodeID != "" && detail.SeriesID != ""), and the two handle errors differently.
They agree today. If a later change edits only one, for example adding caching, season-level entries, or a different guard, the manifest will advertise a series_poster URL that this route rejects, or the reverse. A small shared helper that returns the entry's series ID would keep them in step. The dl.EpisodeID check is needed: series extras and manga chapters also carry a non-empty SeriesID.
There was a problem hiding this comment.
Done in 87c93ad: episodeSeriesID holds the rule (an EpisodeID is required, then the detail's SeriesID), and both the manifest builder and artworkImageURL use it.
| - Artwork and subtitle URLs are authenticated proxy paths on this server. Fetch | ||
| them once while online and cache the bytes locally. | ||
| - Thumbhash fields are inline placeholders for fast offline UI rendering. | ||
| - For an episode, `poster` and `poster_thumbhash` are the episode still and |
There was a problem hiding this comment.
Low (docs). This bullet covers the new fields, but two places in §10 still describe the old set:
- §10.1, the
OfflineAssetrow lists asset kinds asmedia,poster,backdrop,logo,subtitle. It is missingseries_poster, and it now disagrees with the kind lists this PR updated in the artwork route section. - §10.8, "
poster_thumbhashandbackdrop_thumbhashare placeholders while local artwork bytes load." It should also mentionseries_poster_thumbhashfor series-level screens.
A client author who follows §10 would use poster for the series header, but for an episode that's the episode still.
There was a problem hiding this comment.
Fixed in 87c93ad: §10.1 lists series_poster as an asset kind, and §10.8 says an episode's poster is its still and series-level screens use series_poster and series_poster_thumbhash.
|
|
||
| // itemDetailsByID serves one catalog detail per content id; an unknown id is | ||
| // denied like an out-of-scope item. | ||
| type itemDetailsByID map[string]*catalog.ItemDetail |
There was a problem hiding this comment.
Cleanup. mapManifestSource in offline_batch_test.go already does this: a map of *catalog.ItemDetail returning catalog.ErrItemNotFound for unknown IDs, plus a per-ID call counter. Reusing it removes a third GetItemDetail fake. Its calls["show"] counter would also let these tests assert the extra series lookup described in the PR body.
There was a problem hiding this comment.
Done in 87c93ad: the tests use mapManifestSource, and the manifest test checks calls["show"] is 1 after the episode build.
… URLs The manifest and the artwork route now use one helper to find an episode entry's parent series. The series poster URL moves into the domain ArtworkURLs struct (hidden from the v1 JSON), and the v2 manifest converts that struct instead of copying fields, so a new domain field fails to compile until v2 has it. The manifest tests reuse mapManifestSource and check that the series is looked up once. The downloads API guide's offline client notes now list series_poster as an asset kind and say which poster series-level screens use, and the v1 guard's comment says it answers 404 before checking the download.
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
|
From the review summary: the PR body no longer says Android does not read these fields; it now points to Silo-Server/silo-android#432, which already saves them. |
# Conflicts: # contracts/api/v2/fixtures/get_system_info_ok.json # internal/downloads/manifest_test.go
Problem
Related issue: N/A
Validation tasks: none
Offline clients have no series poster for a downloaded show. An episode download's poster is the episode still, so the iOS Downloads screen shows a cropped still or a blurred placeholder where the series poster belongs. This change adds the parent series poster to v2 episode download manifests so clients can save it with each episode.
Approach
v2 episode manifests gain
series_poster_thumbhashandartwork_urls.series_poster.GET /api/v2/downloads/{id}/artwork/series_posterserves the image after checking that the profile can see both the episode and its series; a series the profile can no longer see answers 404, like other offline assets. Movies and series without a poster get neither field.The frozen v1 manifest does not change, and the v1 artwork route answers the new kind with 404. The iOS change that uses these fields is Silo-Server/silo-apple#564. Android already saves them (Silo-Server/silo-android#432).
Validation
internal/downloads,internal/apiv2, andinternal/api/handlers: pass, exceptTestAdminResourceCapabilitiesAndScopeininternal/apiv2, which fails the same way onmain.make lint-changed: no issues. OpenAPI, web types, contract fixtures, and the local-path check are current.Risks
Checklist
AI Disclosure
Note
Add parent series poster to episode download manifests
series_poster_thumbhashand an authenticatedseries_posterartwork URL in the v2 APIdownloads.Service.artworkImageURLresolvesseries_posteronly for episode entries with an accessible parent series; other kinds and non-episodes returnErrAssetNotFoundseries_posterwith 404, and the newOfflineManifestfields carry JSON omission tags so direct v1 serialization omits themseries_posternow get 404 from downloads.go; the v2 manifest projection rejectsseries_posterURLs that are not internal download asset pathsMacroscope summarized c2f3981.