Repository navigation
feat(catalog): list present movies, series and episodes for administrators - #3183
Conversation
…ators GET /api/v2/admin/catalog/items pages the video catalog in content_id order with each item's libraries, first-seen time and one entry per present file (codecs, dynamic range, channels, Atmos, container, bitrate, size, edition). Filters: library_id, type, added_after, content_ids; all bound into the cursor. Two statements per page in one snapshot. GET /api/v2/admin/catalog/capabilities advertises it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
API contracts and examples contracts/api/v2/openapi.json, web/src/api/v2/schema.ts, web/src/api/v2/operations.ts, contracts/api/v2/fixtures/*, docs/admin-catalog-api.md |
Defines the capabilities and item-listing endpoints, schemas, query parameters, responses, and documented behavior. Adds response fixtures for capabilities and a paginated listing. |
Catalog query and version data internal/catalog/admin_item_listing.go, internal/catalog/admin_item_listing_db_test.go, internal/playback/audio_select_v3.go, scripts/ci/db-pins.txt |
Adds filtered, paginated catalog queries and file-version details. Adds database tests and exports the existing Atmos-track check for use by catalog code. |
Endpoint handling and router wiring internal/apiv2/admin_catalog_items.go, internal/apiv2/admin_catalog_items_test.go, internal/apiv2/{document.go,fixtures_test.go,router.go}, internal/api/router.go, internal/api/testdata/media_routes.txt |
Adds the capabilities and listing handlers, including filter validation, cursor handling, and response mapping. Registers the service and routes, and adds endpoint tests and route classifications. |
Priority:
Estimated code review effort: 4 (Complex) | ~45 minutes
Change: Feature
Sequence Diagram(s)
sequenceDiagram
participant AdminClient
participant AdminCatalogItemsHandler
participant ItemRepository
participant Database
AdminClient->>AdminCatalogItemsHandler: Request catalog items with filters and cursor
AdminCatalogItemsHandler->>ItemRepository: ListAdminCatalogItems(filter, after, limit)
ItemRepository->>Database: Query catalog items and file versions
Database-->>ItemRepository: Return page rows and version data
ItemRepository-->>AdminCatalogItemsHandler: Return items and HasMore
AdminCatalogItemsHandler-->>AdminClient: Return collection and next cursor
Possibly related PRs
- Silo-Server/silo-server#3114: Changes catalog listing visibility for titles without library membership, which connects to this PR’s enabled-library membership filtering.
Suggested labels: javascript
Suggested reviewers: rhainland
Merge Risk: 
Minimal · up to 54157
-
No confirmed issue blocks the administrator catalog listing from merging after normal validation.
Security architecture risk: 
Low · up to 54157
-
The listing is read-only and uses existing administrator authorization. It exposes catalog-wide metadata, but not filesystem paths, storage keys, or file contents. No new authorization bypass was established. A monitoring integration currently needs broadly privileged administrator credentials, and production integration coverage remains incomplete.
Retained concerns
No architecture-level concerns identified.Security review details
-
Security Blast Radius
- inferred — Compromise of an admitted administrator credential would permit enumerating video catalog metadata across all enabled libraries on the server. library_id selects which items appear; it is not an authorization boundary, and returned memberships and versions can include other enabled libraries.
Trust Boundaries and Controls
- observed — The new operations enter the existing authentication and authorization chain before handler execution. Required authorization dependencies fail closed. Authentication validates credentials and active session authority; the acting-admin gate separately requires an administrator role and an affirmative configured authorization decision.
- observed — The current scoped-key allowlist contains neither new catalog route, so keys with nonempty scopes are denied before handler execution. Empty-scope keys retain existing account-level access and remain subject to administrator authorization.
Resilience and Maintainability Implications
- observed — Cursors authenticate the operation, account/profile identity, normalized filters, page size, and ordering scope. Tampering or scope changes are rejected. Attacker-supplied filter and cursor-position values reach SQL through parameters rather than interpolated query text.
Hardening Proposals
- proposed — If monitoring integrations should hold less authority than a full administrator, introduce an explicit catalog-read-only key scope for these GET operations instead of requiring an unscoped administrator key. This is a least-privilege proposal, not an observed authorization bypass.
-
Pre-merge checks: 
4
-
Full details: Description check
-
Explanation
The pull request description directly and thoroughly describes the added administrator catalog capabilities and item-listing endpoints, their filters, pagination, authorization, documentation, tests, validation, and risks. It matches the changeset.
-
Finishing Touches: 💡 1
-
📝 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
Comment @coderabbitai help to get the list of available commands.
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:
|
…most two statements A library_id above 2^31-1 reached Postgres as an int4 parameter and came back as a 500; it is now a validation error. A page holding only series skips the versions query, so the docs say "at most two". Co-Authored-By: Claude Opus 5.5 <[email protected]>
Major change: API keys — Server C2 (#1190)This adds two admin API routes to the scoped-key authorization surface. Neither route is in Suggested Suggested fix: No diff — record the affected case and re-test after the scope allowlist change. Automated check: Macroscope check run agent (gpt-6-luna). No validation was performed. Posted via Macroscope — v1 validation impact |
|
Keeping C2 does need a re-check once the scopes PR adds Reply by Claude Code (claude-opus-5-5). |
Brings in the admin:monitor:read scope (#3182) and adds the catalog listing and its capability document to that scope's allowlist. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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:
|
Major change: scoped-key permissions — #1190 C2This diff now admits Suggested fix: Automated check: Macroscope check run agent (gpt-6-luna). No validation was performed. Posted via Macroscope — v1 validation impact |
|
Already in the PR body: Reply by Claude Code (claude-opus-5-5). |
Problem
Related issue: N/A
Validation tasks: changes #1190 C2
A monitoring tool that mirrors the Silo catalog (the first one is Tracearr) has no admin API that lists what the server holds. The viewer catalog routes are scoped to one profile and its libraries, return display cards rather than files, and page in display order, so a tool cannot use them to keep a complete copy. This adds an administrator listing of every movie, series and episode present in an enabled library, with the files behind each one, in an order a mirror can page through and resume.
Approach
GET /api/v2/admin/catalog/items(acting administrator) returns items incontent_idorder with a signed cursor. Each item carries its ids, type, title, year, match status, provider ids, an episode's series and season/episode numbers, the libraries it is in,added_at, andversions: one entry per present file with a stringfile_id,library_id, resolution, video codec, dynamic range, audio codec, channels, Atmos, container, bitrate, size and edition label. No paths or storage keys.library_id,type(movie,series,episode),added_after, andcontent_ids(up to 200, for fetching specific items after an event). All of them are bound into the cursor;content_idsis treated as a set.added_atis the first-seen time: the earliest across the item's libraries, or that library's own time whenlibrary_idis set. It is not a change cursor, and the doc says so.media_itemsandepisodesprimary keys (or the library's membership rows whenlibrary_idis set) and stops after one page of present items.GET /api/v2/admin/catalog/capabilitiesadvertises the listing.(media_folder_id, content_id)index onmedia_item_librarieschanged no case by more than a few ms. The timings are on the evidence page.docs/admin-catalog-api.mddocuments the contract. This is an admin-only native route: Apple and Android have no callers, and Jellyfin clients read items through their own queries, so there is no jellycompat counterpart. The user manual does not describe admin API routes, so it needs no update.API keys:
admin:monitor:read(#3182) now admitsGET /api/v2/admin/catalog/itemsandGET /api/v2/admin/catalog/capabilities; its scope description anddocs/api-keys-api.mdlist them. Other scoped keys are still refused, and an unscoped admin key keeps the access its owner has. This adds allowlist rows, so #1190 C2 (scoped keys against allowed and forbidden operations) needs a re-check after merge.Validation
gofmt,go vet,make lint-changedandmake lint-router-recoveryclean.make test-db-pinspasses (371 pins).make test-gohad two failures that pass alone three times out of three and do not touch this code (markersTestPopulationSyncResumesAfterQuotaAcrossRuns, handlersTestV1AdminUserChangesKeepBreakGlassDB).verify-apiv2-openapi,verify-apiv2-contract,verify-apiv2-fixtures, the committed-artifact test and the otherverify-*targets pass.admin:monitor:readand refuses item files and catalog export; the existing schema walk confirms neither response carries a path, address or storage key.TestListAdminCatalogItemsDB(indb-pins.txt): which items are listed or left out, per-library and earliestadded_at, inclusiveadded_after, paging one item at a time across items and episodes, every present file with the default audio track's facts, and two statements for a page with files. Mutation-checked against first-track audio selection and against dropping the enabled-library filter.content_idsorder-insensitive, validation and member refusals.make test-webfails only thepgs.test.ts16 MiB window timeout, which also fails on main.library_id,type,added_afterandcontent_idsbehaved as documented; disabling a library removed its items; a reused cursor with another filter answered400 invalid_cursor. Refusals: anonymous401, regular account403, key scoped tolibraries:read403, revoked key401; an unscoped admin key gets200. After merging main: a key scoped toadmin:monitor:readgets200on both routes,403on catalog export, and401once revoked.Evidence
Evidence: https://evidence.siloserver.org/r/silo-server/pr-3183/
No visible change in the web app or admin; the evidence page has the API excerpts, the query timings and the test output.
Risks
Additive admin route under
/api/v2, covered by the 1.0 additive-only lock once it ships, so the field names are meant to last. A full walk is one request per 200 items. Anadded_afterwindow that matches few items in a large library is the slowest case measured (70–100 ms for a 78,000-item library), because the planner walks the library in key order.Checklist
AI Disclosure
library_idabove 2^31-1 answered500(now422, confirmed on the sandbox), and the docs overstated "two statements per page" (a page of only series runs one).🤖 Generated with Claude Code
Note
Add admin catalog API for listing present movies, series, and episodes
GET /api/v2/admin/catalog/itemsandGET /api/v2/admin/catalog/capabilitiesto the v2 API. The items endpoint supports filters (library, item type, added-after, content IDs), cursor pagination, and a page size of 1-200 (default 50).admin:monitor:readAPI key scope (api_key_scopes.go), covered by OpenAPI contracts, fixtures, database tests (admin_item_listing_db_test.go), and new docs (admin-catalog-api.md).playback.atmosAudioTrackis renamed to the exportedplayback.AtmosAudioTrack; check the in-file caller in audio_select_v3.go.Macroscope summarized e85280b.