Skip to content

feat(catalog): serve stored metadata and credits on the admin catalog listing - #3571

Merged
Quick104 merged 2 commits into
mainfrom
fix/issue-3568-admin-catalog-metadata
Nov 5, 2026
Merged

Quick104 merged 2 commits into
mainfrom
fix/issue-3568-admin-catalog-metadata

Conversation

@Quick104

@Quick104 Quick104 commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Closes #3568
Related issue: N/A
Validation tasks: none

An admin tool can list every movie, series and episode through GET /api/v2/admin/catalog/items, but it can't see genres, ratings, studios, release or air dates, or cast there. Those fields are only on the profile-scoped item detail. A cleanup tool such as a Maintainerr adapter, whose rules match on those fields, has to look up the key owner's primary profile and read every item as that profile: one request per item, filtered by that profile's restrictions.

This change adds the stored metadata, including dates, to the admin listing rows, and the cast and crew when asked for, so a tool can read a whole library in pages without acting as a profile.

Approach

  • Movie and series rows now carry genres, content_rating, studios, networks, the four stored ratings (rating_imdb, rating_tmdb, rating_rt_critic, rating_rt_audience), and release_date; series rows also carry first_air_date and last_air_date. Dates use item detail's YYYY-MM-DD form. These are the stored values: not localized and not narrowed by any profile. The listing serves every stored rating whether or not title pages show that source, as item detail already does for metadata curators. Episode rows carry only their own air_date; tools read the rest from the series row named by series_id, and a season's last air date is the latest air_date among its episode rows. They come from the media_items row the page query already reads, so a default page still runs two statements.
  • include_people=true adds cast and crew, using the existing CastCredit and CrewCredit shapes from item detail without photos. Credits load in one more statement inside the page's read-only snapshot, so a page with credits runs three. They are off by default because they make a page several times larger. Like every listing filter, include_people is bound into the cursor.
  • getAdminCatalogCapabilities reports item_metadata so tools can tell whether a server returns these fields.
  • File paths stay out of the listing, which still returns no paths or storage keys. That keeps it within the admin:monitor:read API-key scope, and tools can match titles to Radarr or Sonarr through the provider ids the listing already returns.

docs/admin-catalog-api.md documents the fields, the opt-in credits, the statement budget, and one limit for mirrors: renaming or merging a person changes their credits on every item without a catalog.item.changed event, so a mirror that keeps credits picks that up on its next full pass.

This is an admin-only native route. Apple and Android have no callers, and Jellyfin clients read item metadata through their own item queries, so there's no client or jellycompat follow-up. The user manual doesn't describe admin API routes, so it needs no update.

The contract diff tool requires the next pull request that changes the v2 contract to prune approvals left by the last merged one, so this change empties breaking-approvals.json (two listAdminBackups approvals from #3402).

Validation

  • Live on a sandbox with a cloned test library, before (main) and after (this head), over HTTP:
    • Before, the listing had no metadata, the capability had no item_metadata, and include_people answered 422.
    • After, a matched movie's genres, content rating, studios, TMDB rating and release date match its database row, and its 41 stored credits come back as 20 cast and 21 crew with no photo or path fields. A series row's networks, first_air_date and last_air_date, and an episode row's air_date, match their rows; episode rows carry none of the other new fields.
  • An API key scoped to admin:monitor:read, without a profile, gets 200 on the listing with and without include_people. It gets 403 on profile-scoped item detail and on catalog export. A cursor reused with include_people changed answers 400 invalid_cursor, and a request without credentials gets 401.
  • TestListAdminCatalogItemsDB (already in db-pins.txt) now also covers stored metadata and dates, including a zero Rotten Tomatoes score kept as a score; only air_date on episodes; credits only on request; and two statements per page, or three with credits. It passes against a migrated Postgres. On main it does not compile, because the fields it checks don't exist there, so the live before and after is the proof.
  • go build, go vet, gofmt, go mod tidy -diff, and make lint-changed are clean. The catalog and apiv2 package tests pass with a database at this head, and the api package tests passed at the first commit, which the date commit doesn't touch. OpenAPI, web types and fixtures are regenerated, and verify-apiv2-openapi, -web-types, -contract (16 additive changes), -fixtures, the committed-artifact test, verify-route-inventory, verify-local-paths and verify-size-ratchet pass. Web lint and format checks pass. The full make test-go and make test-web suites were not run locally.

Evidence

Evidence: https://evidence.siloserver.org/r/silo-server/issue-3568/

No visible change in the apps, web app or web admin. The evidence page has the before and after API responses, the scoped-key results and the credit-volume measurements.

Risks

Additive fields, one query parameter and one capability on an admin-only /api/v2 operation. Once 1.0 locks the contract, these names are permanent.

Credits are unbounded per item. On the test library an item averages about 40 credits, so a 200-item page with include_people carries roughly 8,000 credits, about 1 MB. A synthetic worst case of 200 items with 150 credits each (30,000 credits) read in 62 ms and serialized to about 4 MB. Tools can lower limit if pages get too large.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.
  • Each test this pull request adds meets "Decide what to test" in CONTRIBUTING.md.
  • The Evidence section shows every change a user can see, or says there is none.

AI Disclosure

  • Harness: Claude Code in T3 Code
  • Tool(s): Claude Code, GitHub CLI
  • Model(s): claude-opus-5-5 (implementation); gpt-6.1-sol and claude-opus-5-5 (plan review); claude-opus-5-5 and claude-sonnet-5-5 (code review)
  • Involvement: Fully AI-generated; human verification is the maintainer's review
  • Adversarial review:
    • Before implementation, a plan round ran with gpt-6.1-sol (attack) and claude-opus-5-5 (cut). The cut kept one capability field instead of two, reused the existing credit types, and bound include_people into the cursor. The attack's two findings became the documented credit-event limit and the measured page size above.
    • A medium-level multi-agent code review followed. It added plex_guid to the credits, which item detail already returns, simplified the credits loader, and fixed the docs wording on the statement budget. Its finding about the pruned approvals was answered with the contract tool's pruning rule.
    • A simplify pass made no changes.
    • A gpt-6.1-sol background review of the first commit found nothing. The release and air dates were added afterwards at the issue reporter's request; they follow the same pattern and were checked live and in the DB test.

🤖 Generated with Claude Code

Note

Add stored metadata and cast/crew credits to admin catalog listing

  • Adds an opt-in include_people query parameter to the admin catalog listing, reported via a new item_metadata capability. When set, the listing loads cast and crew through attachAdminCatalogCredits in admin_item_listing.go.
  • AdminCatalogItem gains fields for genres, content rating, studios, networks, four stored ratings, and release/air dates. Movies and series get these from the page query; episodes get only an air date.
  • Credits are loaded in a separate query and split into cast and crew per item; episodes get no credits. Credits stay nil when not requested, and the test distinguishes a zero rating from an absent one.
  • Updates the OpenAPI contract, generated TypeScript schema, fixture, and admin-catalog-api.md. Risk: contracts/api/v2/breaking-approvals.json empties the approvals list — check that no pending contract approvals depended on the prior entries.

Macroscope summarized 946c1b7.

… listing

listAdminCatalogItems now returns each movie's and series' genres, content
rating, studios, networks and the four stored ratings, and with
include_people=true its cast and crew. Admin tools that match rules on
metadata, such as library cleanup, can read a whole library in pages without
acting as a profile. getAdminCatalogCapabilities reports item_metadata.

Closes #3568

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@silo-triage silo-triage Bot added the size/L 200–499 added + deleted lines (all files); change volume, not priority. label Nov 5, 2026
@coderabbitai

coderabbitai Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The admin catalog API now returns stored metadata for catalog items and can optionally include cast and crew. The API capability, schemas, and documentation describe these additions. The breaking approvals file also removes two approvals for listAdminBackups.

Changes: Admin catalog metadata

Layer / File(s) Summary
Metadata and people contract
contracts/api/v2/openapi.json, web/src/api/v2/schema.ts, docs/admin-catalog-api.md, contracts/api/v2/fixtures/admin_catalog_capabilities.json
The API schemas and documentation describe metadata fields for movies, series, and episodes, the item_metadata capability, and the optional include_people parameter. The capability fixture enables item_metadata.
Catalog metadata retrieval
internal/catalog/admin_item_listing.go, internal/catalog/admin_item_listing_db_test.go
The catalog listing query returns stored metadata. When people are requested, it loads ordered cast and crew for movie and series rows. Database tests check returned metadata, credits, and query counts.
API response mapping and capability
internal/apiv2/admin_catalog_items.go
The handler passes include_people to the catalog filter, maps metadata into API responses, and advertises the item_metadata capability.

Breaking approval update

Layer / File(s) Summary
Remove backup-listing approvals
contracts/api/v2/breaking-approvals.json
The approvals array no longer contains two listAdminBackups response-property enum-value approvals.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Feature · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant AdminAPIClient
  participant AdminCatalogItems
  participant ListAdminCatalogItems
  participant CatalogDB
  AdminAPIClient->>AdminCatalogItems: Request catalog page with include_people
  AdminCatalogItems->>ListAdminCatalogItems: Pass item type and People filter
  ListAdminCatalogItems->>CatalogDB: Query page metadata and, when enabled, credits
  CatalogDB-->>ListAdminCatalogItems: Return item rows and optional credits
  ListAdminCatalogItems-->>AdminCatalogItems: Return catalog items
  AdminCatalogItems-->>AdminAPIClient: Return mapped API response
Loading

Possibly related PRs

Suggested reviewers: rhainland, blurbery

Merge Risk: Minimal · up to 946c1

The change adds stored metadata and opt-in cast and crew to the admin catalog listing, along with a capability flag and matching documentation. No concrete merge-blocking risk remains after review.

Security architecture risk: Minimal · up to 946c1

The additional information remains behind the existing administrator-only, read-only endpoint. Authorization and page consistency are preserved, and no introduced or materially worsened security issue was identified.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • observed — The expanded response can cover stored metadata and requested person credits across enabled libraries accessible to the administrator listing. Admin-owned admin:monitor:read keys inherit this expanded route response, while the scope continues to exclude catalog export and item-file routes.

Security Findings and Attack Paths

  • inferred — The inspected change does not establish a new non-admin path to catalog metadata or credits. Its effective exposure change is additional fields for callers already authorized to perform server-wide administrator catalog reads.

Trust Boundaries and Controls

  • observed — The route retains ClassActingAdmin. Authentication, viewer access, and acting-admin authorization execute before the handler. API-key scopes narrow route access while preserving the owning user's role; an allowed monitor scope does not independently grant administrator authority.
  • observed — The credit query binds only returned movie and series IDs and does not fetch photo data. Credit splitting therefore leaves photo URLs, thumbhashes, and paths unpopulated for this listing.

Resilience and Maintainability Implications

  • observed — The heavier credit projection is opt-in and uses one page-scoped query rather than per-item queries. Repository tests assert two statements by default, three with credits, and omission of credits when not requested.
Pre-merge checks: Passed 4 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Docstring Coverage Inconclusive Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed

Check name Status Explanation
Title check Passed The title clearly and concisely describes the primary change: serving stored metadata and credits in the admin catalog listing.
Description check Passed The description directly explains the metadata and credit changes, API behavior, validation, risks, and documentation updates.
Linked Issues check Passed Directly linked issue #3568 asks that an admin API client read item metadata without acting as a profile, ideally on admin catalog rows, with a capability flag. The reviewed head meets these requireme…
Out of Scope Changes check Passed Each changed area traces to #3568 or to the contract workflow that the feature requires:

- internal/catalog/admin_item_listing.go and internal/apiv2/admin_catalog_items.go: new listing fields, includ…
Full details: Linked Issues check

Explanation

Directly linked issue #3568 asks that an admin API client read item metadata without acting as a profile, ideally on admin catalog rows, with a capability flag. The reviewed head meets these requirements for the fields the issue names:

  • Genres, ratings, studios: movie and series rows in internal/catalog/admin_item_listing.go carry genres, content_rating, studios, networks, and the four stored ratings. The values are stored, not profile-scoped, so profile restrictions and watch state do not change them.
  • Cast: include_people=true adds cast and crew through attachAdminCatalogCredits, using the item detail credit shapes. Credits are off by default and load in one extra statement inside the page snapshot.
  • Paged reads: the fields appear on listing rows, so a library can be read in pages instead of one detail request per item.
  • Capability flag: getAdminCatalogCapabilities reports item_metadata. The OpenAPI contract, generated TypeScript schema, and fixture match this change.
  • Date fields: release_date for movies, first_air_date and last_air_date for series, and air_date for episodes. These follow the issue comments and the commit history.

Tests: TestListAdminCatalogItemsDB covers stored metadata, zero-valued ratings, episode field limits, opt-in credits, and the two- and three-statement page budgets. The PR reports that it passes against migrated Postgres. I did not run it. The test and the stated live before and after results are the evidence for this verdict.

Deliberate gap: the issue Problem text lists file paths among the fields that only profile-scoped detail returns. The listing still returns no paths or storage keys. The PR states this is to stay within the admin:monitor:read scope. The issue's proposed behavior asks for full metadata without a profile, and the named consumer needs (genres, ratings, studios, people) are covered. This verdict treats the path exclusion as a documented scope decision, not an unmet requirement. The maintainer should confirm that decision.

Full details: Out of Scope Changes check

Explanation

Each changed area traces to #3568 or to the contract workflow that the feature requires:

  • internal/catalog/admin_item_listing.go and internal/apiv2/admin_catalog_items.go: new listing fields, include_people filter and handler input, credit loader, and item_metadata capability. These implement the issue.
  • internal/catalog/admin_item_listing_db_test.go: tests for the new fields and the statement budget.
  • contracts/api/v2/openapi.json, web/src/api/v2/schema.ts, and contracts/api/v2/fixtures/admin_catalog_capabilities.json: generated contract artifacts for the new fields and capability.
  • docs/admin-catalog-api.md: documents the new fields, opt-in credits, cursor binding, and the statement budget.
  • contracts/api/v2/breaking-approvals.json: approvals array emptied, removing two listAdminBackups approvals from #3402. The PR states that the contract diff tool requires the next v2 contract change to prune prior approvals. This is contract housekeeping tied to this change. I did not inspect the contract tool, so this verdict relies on the PR's stated rule.

No change adds unrelated behavior. The credit DTOs reuse existing item detail shapes, and plex_guid comes from the same shape, so these changes stay within the feature.

Full details: Docstring Coverage

Explanation

Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 4 functions across 3 files. (5 skipped: 4 unsupported, 1 too large.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches

Generate docstrings

  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1e3770fd-e3ce-4962-b090-96f81630450c
Commits

Reviewing files that changed from the base of the PR and between a5ec117 and 946c1b7.

Files selected for processing: 8

  • contracts/api/v2/breaking-approvals.json
  • contracts/api/v2/fixtures/admin_catalog_capabilities.json
  • contracts/api/v2/openapi.json
  • docs/admin-catalog-api.md
  • internal/apiv2/admin_catalog_items.go
  • internal/catalog/admin_item_listing.go
  • internal/catalog/admin_item_listing_db_test.go
  • web/src/api/v2/schema.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-05T20:34:37.275729Z 946c1b7 New commits
🔒 Security Review ✅ Completed 2026-11-05T20:36:50.114271Z 946c1b7 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@silo-kody

silo-kody Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@silo-triage silo-triage Bot added api-v2 API v2 / Huma migration program (epic #135); long-running, stacked by phase enhancement New feature or request go Pull requests that update go code priority: P2 Limited scope, workaround exists, or polish labels Nov 5, 2026
Comment thread internal/catalog/admin_item_listing.go Resolved
@johnschult

johnschult commented Nov 5, 2026 •

Copy link
Copy Markdown

@Quick104 thanks, this covers the Maintainerr adapter’s genre, rating, studio and people rules. One addition that would save per-item detail reads: date fields on the rows. Maintainerr has rules on release date, “last episode aired”, and “season’s last episode aired”, and the listing only has year. release_date on movies, first_air_date on series and air_date on episodes would cover them. If you’d rather keep this PR to #3568’s scope, I can file it separately.

Movie and series rows carry release_date, and series also first_air_date
and last_air_date; episode rows carry air_date. Cleanup rules on release
date and last aired episode no longer need a detail read per item.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@silo-kody

silo-kody Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@Quick104

Quick104 commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

Added in 946c1b7. Movie and series rows now carry release_date, series rows also carry first_air_date and last_air_date, and episode rows carry air_date, all as YYYY-MM-DD.

For "last episode aired", use the series row's last_air_date; it's the date the metadata provider reports. For "season's last episode aired", take the latest air_date among that season's episode rows (type=episode, filtered by series_id and season_number). The docs in docs/admin-catalog-api.md describe both.

item_metadata on the capabilities endpoint covers the dates too, since none of this has shipped yet.

🤖 Claude Code (claude-opus-5-5)

@Quick104
Quick104 merged commit 0d3f510 into main Nov 5, 2026
20 checks passed
@Quick104
Quick104 deleted the fix/issue-3568-admin-catalog-metadata branch November 5, 2026 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api-v2 API v2 / Huma migration program (epic #135); long-running, stacked by phase enhancement New feature or request go Pull requests that update go code priority: P2 Limited scope, workaround exists, or polish size/L 200–499 added + deleted lines (all files); change volume, not priority.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feature] Read full item details as an admin, without a profile

2 participants