Skip to content

feat(catalog): list present movies, series and episodes for administrators - #3183

Merged
Quick104 merged 3 commits into
mainfrom
feat/admin-catalog-listing
Oct 28, 2026
Merged

Quick104 merged 3 commits into
mainfrom
feat/admin-catalog-listing

Conversation

@Quick104

@Quick104 Quick104 commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

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 in content_id order 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, and versions: one entry per present file with a string file_id, library_id, resolution, video codec, dynamic range, audio codec, channels, Atmos, container, bitrate, size and edition label. No paths or storage keys.

  • Filters: library_id, type (movie, series, episode), added_after, and content_ids (up to 200, for fetching specific items after an event). All of them are bound into the cursor; content_ids is treated as a set.
  • "Present" means a membership row in an enabled library, the same rows Recently Added uses. Books, podcasts and their episodes are left out, as are episodes a provider lists that no library has.
  • added_at is the first-seen time: the earliest across the item's libraries, or that library's own time when library_id is set. It is not a change cursor, and the doc says so.
  • The video facts come from the file's primary video track and the audio facts from one track: the one playback picks with no language preference. That keeps codec, channels and Atmos consistent with each other, unlike the card overlay, which mixes tracks.
  • Each page is at most two statements in one read-only snapshot (one when it holds only series). The page query walks the media_items and episodes primary keys (or the library's membership rows when library_id is set) and stops after one page of present items.
  • GET /api/v2/admin/catalog/capabilities advertises the listing.
  • No migration. On a large fixture (80,000 movies, 40,000 audiobooks, 300,000 known episodes) most pages took 1–30 ms, and adding a (media_folder_id, content_id) index on media_item_libraries changed no case by more than a few ms. The timings are on the evidence page.

docs/admin-catalog-api.md documents 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 admits GET /api/v2/admin/catalog/items and GET /api/v2/admin/catalog/capabilities; its scope description and docs/api-keys-api.md list 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

  • Go: build, gofmt, go vet, make lint-changed and make lint-router-recovery clean. make test-db-pins passes (371 pins). make test-go had two failures that pass alone three times out of three and do not touch this code (markers TestPopulationSyncResumesAfterQuotaAcrossRuns, handlers TestV1AdminUserChangesKeepBreakGlassDB).
  • Contract: OpenAPI, fixtures, web types and route manifest regenerated after merging main; verify-apiv2-openapi, verify-apiv2-contract, verify-apiv2-fixtures, the committed-artifact test and the other verify-* targets pass.
  • Scope: the middleware allowlist test admits both routes for admin:monitor:read and refuses item files and catalog export; the existing schema walk confirms neither response carries a path, address or storage key.
  • New DB pin TestListAdminCatalogItemsDB (in db-pins.txt): which items are listed or left out, per-library and earliest added_at, inclusive added_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.
  • New API test: cursor bound to each filter and the caller, content_ids order-insensitive, validation and member refusals.
  • Web: lint, format, build and bundle budget pass; make test-web fails only the pgs.test.ts 16 MiB window timeout, which also fails on main.
  • Sandbox, end to end over HTTP against a cloned test library (32 movies, 7 series, 95 episodes): a full walk returned each present item once in byte order with 184 versions, matching the database; library_id, type, added_after and content_ids behaved as documented; disabling a library removed its items; a reused cursor with another filter answered 400 invalid_cursor. Refusals: anonymous 401, regular account 403, key scoped to libraries:read 403, revoked key 401; an unscoped admin key gets 200. After merging main: a key scoped to admin:monitor:read gets 200 on both routes, 403 on catalog export, and 401 once 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. An added_after window 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

  • 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
  • Involvement: Fully AI-generated; human verification is the maintainer's review
  • Adversarial review: an independent Claude Code reviewer subagent (claude-opus-5-5) read the diff and the schema without my conclusions. It confirmed paging, filters, cursor binding and authorization, and found two low-severity issues, both fixed in 541571e: a library_id above 2^31-1 answered 500 (now 422, 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

  • Adds GET /api/v2/admin/catalog/items and GET /api/v2/admin/catalog/capabilities to 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).
  • The listing runs in a read-only repeatable-read transaction in admin_item_listing.go. It queries movies/series and episodes in content-ID order, loads file versions in a batch query (two SELECTs per page), and excludes series items from file-version loading.
  • Content IDs are normalized to a sorted, deduplicated set; up to 200 content IDs and an 8192-character cursor are accepted. Capabilities report whether listing is served and the content-ID limit.
  • Both endpoints are admitted by the admin:monitor:read API 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).
  • Behavioral Change: playback.atmosAudioTrack is renamed to the exported playback.AtmosAudioTrack; check the in-file caller in audio_select_v3.go.

Macroscope summarized e85280b.

…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]>
@silo-triage silo-triage Bot added the size/XXL 1000–2999 added + deleted lines (all files); change volume, not priority. label Oct 27, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 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-10-28T13:35:19.833586Z — New commits
🔒 Security Review ✅ Completed 2026-10-28T13:35:07.038941Z e85280b 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.

@coderabbitai

coderabbitai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

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: 7298cfc3-8988-4882-8e2d-e7e3b8c0eed6
Commits

Reviewing files that changed from the base of the PR and between 25bf16e and 541571e.

Files selected for processing: 18
  • contracts/api/v2/fixtures/admin_catalog_capabilities.json
  • contracts/api/v2/fixtures/index.json
  • contracts/api/v2/fixtures/list_admin_catalog_items_ok.json
  • contracts/api/v2/openapi.json
  • docs/admin-catalog-api.md
  • internal/api/router.go
  • internal/api/testdata/media_routes.txt
  • internal/apiv2/admin_catalog_items.go
  • internal/apiv2/admin_catalog_items_test.go
  • internal/apiv2/document.go
  • internal/apiv2/fixtures_test.go
  • internal/apiv2/router.go
  • 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
  • web/src/api/v2/operations.ts
  • 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; 0 remain after this review.

Walkthrough

Adds administrator catalog capabilities and paginated item-listing endpoints. The listing applies library, type, date, and content-ID filters, returns item and file-version metadata, and uses filter-bound cursors. The changes also add API contracts, documentation, fixtures, database tests, and router wiring.

Changes: Administrator catalog listing

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: Normal

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
Loading

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: Passed 4
Check name Status Explanation
Title check Passed The title clearly and concisely summarizes the main change: adding administrator access to present movies, series, and episodes.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The pull request description directly and thoroughly describes the added administrator catalog capabilities and item-listing endpoints, their filters, pagination, authorization, documentation, tests, …
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

silo-kody Bot commented Oct 27, 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 Oct 27, 2026
…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]>
@coderabbitai coderabbitai Bot added the javascript Pull requests that update javascript code label Oct 27, 2026
@macroscopeapp

macroscopeapp Bot commented Oct 27, 2026

Copy link
Copy Markdown

Major change: API keys — Server C2 (#1190)

This adds two admin API routes to the scoped-key authorization surface. Neither route is in apiKeyScopeRoutes, so RequireAuth denies scoped keys before ClassActingAdmin; an unscoped admin key still reaches the admin gate. The C2 result on build 807 predates these operations and does not establish their scope behavior. The PR must explain why this changes validated behavior, and #1190 C2 needs re-validation after merge once the intended admin:monitor:read allowlist entries are present.

Suggested Validation tasks: line: Validation tasks: changes #1190 C2

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

@Quick104

Copy link
Copy Markdown
Contributor Author

Keeping Validation tasks: none. #1190 C2 checks that scoped keys reach the operations their scopes list, are refused everywhere else, and stop working once rotated or revoked. This PR leaves apiKeyScopeRoutes and RequireAuth unchanged. docs/api-keys-api.md already says a scoped key is refused on any route its scopes don't name, "including routes added after the key was issued", and the two new routes follow that rule: on the sandbox, a key scoped to libraries:read got 403 and a revoked key got 401. Every new admin route has this property, so it doesn't change the validated behavior.

C2 does need a re-check once the scopes PR adds GET /api/v2/admin/catalog/items and GET /api/v2/admin/catalog/capabilities to the admin:monitor:read allowlist. That PR changes the allowlist, so its Validation tasks: line should name #1190 C2.

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

silo-kody Bot commented Oct 28, 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

Copy link
Copy Markdown
Contributor Author

Update: #3182 merged first, so this PR now adds the two catalog routes to the admin:monitor:read allowlist (e85280b, merging main). That changes the scope surface #1190 C2 covers, so the Validation tasks: line now reads changes #1190 C2.

Note by Claude Code (claude-opus-5-5).

@macroscopeapp

macroscopeapp Bot commented Oct 28, 2026

Copy link
Copy Markdown

Major change: scoped-key permissions — #1190 C2

This diff now admits admin:monitor:read API keys to GET /api/v2/admin/catalog/items and /capabilities through the RequireAuth allowlist; the acting-admin check still applies. This permission surface was not covered by #1190 C2's build 807 validation. The case needs re-validation after merge, and the PR must explain why validated behavior changes; its description still says these allowlist entries will be added in a separate PR.

Suggested fix: Validation tasks: changes #1190 C2

Automated check: Macroscope check run agent (gpt-6-luna). No validation was performed.

Posted via Macroscope — v1 validation impact

@Quick104

Copy link
Copy Markdown
Contributor Author

Already in the PR body: Validation tasks: changes #1190 C2, and the API keys paragraph now says this PR adds the two admin:monitor:read rows after #3182 merged first. The check ran against the description from before that edit.

Reply by Claude Code (claude-opus-5-5).

@Quick104
Quick104 merged commit 366abc3 into main Oct 28, 2026
26 checks passed
@Quick104
Quick104 deleted the feat/admin-catalog-listing branch October 28, 2026 14:24
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 javascript Pull requests that update javascript code priority: P2 Limited scope, workaround exists, or polish size/XXL 1000–2999 added + deleted lines (all files); change volume, not priority.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant