Skip to content

fix(apiv2): reject an unknown match status in the admin metadata edit - #2940

Merged
Quick104 merged 2 commits into
Silo-Server:mainfrom
Rhainland:fix/2873-validate-match-status
Oct 23, 2026
Merged

Quick104 merged 2 commits into
Silo-Server:mainfrom
Rhainland:fix/2873-validate-match-status

Conversation

@Rhainland

@Rhainland Rhainland commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Closes #2873
Related issue: N/A
Validation tasks: changes #1210 C1; changes #1211 C1

An administrator or curator could write any string to an item's match status through the metadata edit. The web Edit Metadata dialog did exactly that for series, with a Continuing/Ended select. An item whose match status is not matched drops out of search indexing, semantic coverage, enrichment and local sidecar queries until a refresh resets it. This change makes PATCH /api/v2/admin/items/{id}/metadata accept only pending, matched or unmatched for status and removes the dialog's select.

Approach

status on the v2 request is now a closed enum. Any other value fails Huma validation with 422 validation_failed before the service runs, as docs/architecture/api-contract.md requires for request enums. null still leaves the value unchanged. I kept the field instead of removing it because the server already treats status: "matched" as a manual match (it clears the admin's ignore). ambiguous is left out because the scanner sets it, and an admin has no reason to.

oasdiff reports the enum as request-property-became-enum, a breaking change, so contracts/api/v2/breaking-approvals.json carries a pre-lock approval for it. The OpenAPI artifact, the generated web types and docs/admin-catalog-api.md are updated.

The web dialog stops sending status. This removes the same lines #2254 removes, so the bundled client keeps working whichever pull request merges first. The other one then has a trivial rebase.

Frozen /api/v1 uses the same service and still accepts any string. silo-apple and silo-android don't send this field. jellycompat has no equivalent write.

Validation

  • Extended the v2 transport test: "Ended" gets 422 without reaching the service, and a valid status and null pass. It failed on main with a 200.
  • Against a local server with a scanned series: "Ended" returned 422 and the stored status didn't change. matched and unmatched were stored, and null left the status alone.
  • Go: build, vet, internal/apiv2 and internal/contractspec tests, make lint-changed and gofmt pass.
  • Contracts: verify-apiv2-openapi, verify-apiv2-contract (with the approval), verify-apiv2-fixtures, verify-apiv2-web-types, the route inventory, the migration ledger and the v1 route freeze pass.
  • Web: typecheck, eslint (no new warnings), prettier, and the dialog and query-hook vitest files pass.
  • Not run locally: the full make test-go, make test-web, the bundle budget check and the remaining repo-wide verify targets.

Evidence

Evidence: https://evidence.siloserver.org/r/silo-server/pr-2940/

Edit Metadata dialog for a series, same item and data. On desktop and mobile web, the Status select is gone.

Surface and build: web, desktop at 1440 px and mobile at 390 px; before is main, after is this branch.

API: the same request against the real /api/v2 handler, run in-process with the handler test's metadata service fake (the 422 comes from request validation, before the service is called). Before is main at be6527e50; after is this branch at a40a6b2a6.

PATCH /api/v2/admin/items/item-1/metadata  {"status":"Ended"}
before: 200 {"content_id":"item-1", ...}
after:  422 {"type":".../problems/validation_failed","title":"Validation failed","status":422,"errors":[{"location":"body.status","code":"invalid_enum","detail":"expected value to be one of \"pending, matched, unmatched\""}]}

PATCH /api/v2/admin/items/item-1/metadata  {"status":"matched"}
after:  200 {"content_id":"item-1", ...}

Risks

A client that sends a status other than these three now gets 422 instead of a silent write. No known client does. The user manual doesn't mention the Status field.

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 (via T3 Code)
  • Tool(s): Claude Code; Codex CLI (code review)
  • Model(s): claude-opus-5-5; gpt-6.1-sol (code review)
  • Involvement: Fully AI-generated, human verified
  • Adversarial review: Independent reviews of the branch diff by claude-opus-5-5 and gpt-6.1-sol covered correctness, repo standards and the issue. Neither found a correctness problem. They noted that the dialog change needs evidence and that removing the select overlaps fix(metadata): keep manual metadata edits through refresh and show them in home rails #2254; both points are covered above.

PATCH /api/v2/admin/items/{id}/metadata wrote any string to
media_items.status, the match status. An item whose status is not
matched drops out of search indexing, enrichment and sidecar queries
until a refresh. The request schema now declares status as a closed
enum of pending, matched and unmatched, so other values fail with 422
before reaching the service; null still means no change.

The web Edit Metadata dialog stops sending its series Continuing/Ended
select through this field, the same removal Silo-Server#2254 makes, so the bundled
client keeps working whichever lands first.

Closes Silo-Server#2873
@coderabbitai

coderabbitai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 51 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ 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: 05fc60e1-fce7-4032-b03c-bf5e2ccd53dc
📥 Commits

Reviewing files that changed from the base of the PR and between be6527e and a40a6b2.

📒 Files selected for processing: 8
  • contracts/api/v2/breaking-approvals.json
  • contracts/api/v2/openapi.json
  • docs/admin-catalog-api.md
  • internal/apiv2/admin_catalog_item_metadata.go
  • internal/apiv2/admin_catalog_item_metadata_test.go
  • web/src/api/v2/schema.ts
  • web/src/components/EditMetadataDialog.tsx
  • web/src/hooks/queries/items.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@silo-kody

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

@macroscopeapp

macroscopeapp Bot commented Oct 22, 2026

Copy link
Copy Markdown

The PR changes what users and API clients see, but the Evidence section lists captures as “to be attached” and includes no actual captures or response excerpts.

  • web/src/components/EditMetadataDialog.tsx: the series Status selector is removed. Please attach before-and-after screenshots of the same dialog and item on desktop and mobile; the surface and builds are already identified.
  • internal/apiv2/admin_catalog_item_metadata.go: unsupported status values now return 422 instead of being accepted. Please include before-and-after API response excerpts for the same request.

Automated check: Macroscope check run agent (gpt-6-luna). Evidence was not reviewed for correctness.

Posted via Macroscope — Visible change evidence

@silo-triage silo-triage Bot added api-v2 API v2 / Huma migration program (epic #135); long-running, stacked by phase bug Something isn't working go Pull requests that update go code javascript Pull requests that update javascript code priority: P2 Limited scope, workaround exists, or polish size/M 50–199 added + deleted lines (all files); change volume, not priority. labels Oct 22, 2026
@macroscopeapp

macroscopeapp Bot commented Oct 22, 2026

Copy link
Copy Markdown

Major change: #1210 C1 (Server) and #1211 C1 (Web admin). The v2 metadata PATCH now rejects non-match status values, and the Edit Metadata dialog no longer exposes the Series Status control. The PR must explain why this observed behavior and control change; its description does, and both cases need re-validation after merge. Their issue comments also report stale home-rail behavior, which this diff does not change and remains covered by open PR #2254.

The #1210/#1211 C2 lock/rescan checks do not set status, so their steps and outcomes are unchanged. The task bodies still say Not run; the separate issue comments describe AI-run results, not human validation.

Suggested fix: No diff; retain Validation tasks: changes #1210 C1 and #1211 C1.

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

Posted via Macroscope — v1 validation impact

@macroscopeapp

macroscopeapp Bot commented Oct 22, 2026

Copy link
Copy Markdown

The Validation tasks: line should be corrected for the validation record. #1210 C1 and #1211 C1 both show Not run in their task Results tables. Their comments describe AI-run local sandbox checks and explicitly state they are not validator sign-off, so this PR does not invalidate or unblock a recorded result.

Suggested fix:

- Validation tasks: changes #1210 C1 and #1211 C1 (the series Status edit both report as failing on `main`)
+ Validation tasks: none

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

Posted via Macroscope — v1 validation impact

@Rhainland

Copy link
Copy Markdown
Contributor Author

The line now reads Validation tasks: changes #1210 C1; changes #1211 C1. That keeps the second Macroscope comment's reading, not the latest one's none.

changes means the PR changes behavior a case exercises. It doesn't need an earlier passed result. #1210 C1 edits fields through the v2 metadata PATCH, which now rejects a status other than a match status. #1211 C1 edits core fields in the Edit Metadata dialog, which no longer has the series Status control. Both cases are Not run, so neither has a result to invalidate, but both need to run on a build with this change. C2 on both tasks doesn't set status, so it's unaffected. I also dropped the parenthetical note: it describes the AI-run comments, which aren't the validation record.

@Quick104 Quick104 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One low-severity finding, below. The rest of the review is in the summary comment.

AirTimezone *string `json:"air_timezone,omitempty" nullable:"true" doc:"IANA time zone; null clears it"`
AirDate *string `json:"air_date,omitempty" nullable:"true" doc:"Season or episode air date; null clears it"`
Status *string `json:"status,omitempty" nullable:"true"`
Status *string `json:"status,omitempty" nullable:"true" enum:"pending,matched,unmatched" doc:"Match status; null leaves it unchanged"`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Low: the published schema rejects the null this field documents. Huma writes the field as "type": ["string", "null"] and "enum": ["pending", "matched", "unmatched"]. In JSON Schema 2020-12, enum applies on its own, so a validator rejects {"status": null}: jsonschema.Draft202012Validator gives None is not one of ['pending', 'matched', 'unmatched']. The server accepts it as "unchanged", as the new transport test shows. Clients that validate requests against the OpenAPI document, or generate strict types from it, would refuse a request the API accepts. The bundled web types aren't affected.

ProfileUpdate.max_playback_quality and DownloadSubscriptionPatchBody.quality already have the same shape on main, so the fix belongs in v2 schema generation (add null to the enum of a nullable field), not in this field. I filed #2980 for it. It changes these same lines, so it should follow this PR. Nothing needs to change on this branch.

@Quick104

Copy link
Copy Markdown
Contributor

Review summary

Reviewed head: a40a6b2a6. I pushed no commits; nothing on the branch needed fixing.

The change does what it says. status on PATCH /api/v2/admin/items/{id}/metadata now accepts only pending, matched or unmatched, and anything else gets 422 validation_failed before the service runs. The dialog no longer sends the Continuing/Ended value that was landing in the match-status column.

Checked

  • The extended TestAdminItemMetadataTransport fails on the base (be6527e50): "Ended" gets 200 there. It passes on the head.
  • Rebased onto current main (19f59ef6f, which includes the fix(apiv2): declare date, URL, and language formats in the v2 schema #2929 format changes), the branch rebases cleanly. verify-apiv2-openapi and verify-apiv2-contract pass there, and the approval fingerprint still matches.
  • Nothing in web/src still sends status. Current Apple and Android sources don't call this endpoint, and jellycompat has no equivalent write.
  • Item detail on v2 doesn't return the match status, so a client can't read back ambiguous and echo it into this PATCH.

Findings

For the maintainers to settle

  • Frozen v1 PATCH /api/v1/admin/items/{id}/metadata still stores any string through the same service, as the PR body says. Moving the check into the shared service would also narrow v1, which needs the critical-bridge-fix exception. No first-party client sends status on v1, so leaving v1 alone seems reasonable.
  • Rows the old dialog already set to Continuing or Ended keep that value. The enrichment selector only picks unmatched, pending and ambiguous, so those items won't be picked up on their own; a manual refresh is needed. A one-off repair is a separate decision.
  • After this change, the web UI has no way to edit a series' airing status. The removed control never wrote show_status, so nothing that worked is lost, but a show_status field on this PATCH would be a follow-up.

Validated features

No passed case on the v1.0 board reaches this diff. #1210 C1 and #1211 C1 are still Not run. By the AGENTS.md rule, which counts passed cases only, the line would be Validation tasks: none. The body's changes #1210 C1; changes #1211 C1 instead tells validators to run those cases on a build with this change. Either works for the record; the maintainer can choose.

User manual: unaffected. The metadata pages on siloserver.org don't describe the Status select.

Apple/Android parity: no client change needed. Neither app calls this endpoint.

Cross-provider review: one round by gpt-6.1-sol (Codex) at xhigh. It produced the schema finding above and found nothing else.

Fit: 9/10 · Readiness: 9/10 — ready

Fit: it closes a data-integrity hole at the v2 boundary, where the contract rules want request enums enforced, and removes a control that wrote the wrong column. It adds no new surface. Readiness: a test that fails on the base proves the fix, the contract checks pass against current main, and the one remaining issue is a systemic schema detail tracked separately.

@Quick104
Quick104 merged commit 8f11994 into Silo-Server:main Oct 23, 2026
22 checks passed
Quick104 added a commit to blurbery/silo-server that referenced this pull request Oct 23, 2026
Silo-Server#2940's schema change is on main, so its approval matches no change and
the contract gate fails any branch that changes the OpenAPI document.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Quick104 added a commit that referenced this pull request Nov 5, 2026
* feat(sections): let an admin keep a hero banner row off the apps

The web shows a featured row as a banner at the top of a page, but the
native apps show it as a regular row, so a row an admin made the web's hero
(Discover, say) also turns up as an extra row on every app with no way to
hide it there.

Admin sections gain web_only. Only a featured row keeps it: a save that
leaves the row not featured stores false, and so does another row taking the
page's hero spot. The viewer section reads (home and library layout, the
all-sections list and the single-section items, on v2 and the frozen v1
routes) answer a web-only hero only to a caller whose X-Silo-Client-Family is
web. Anyone else, including a caller that sends no family, never gets it:
layouts and lists leave it out and reading it alone answers 404. A profile
that turns the row's hero banner off gets a regular row, which every client
receives. The v2 admin create and PATCH accept web_only once
getAdminSectionCapabilities reports it, and the frozen v1 admin bodies are
unchanged.

The admin row editor shows a "Show in the apps" switch under Hero banner on
a server that supports it, and the row list tags such a row "Hero banner ·
Web only".

* fix(web): say the apps show a web-only hero's row too, not as a regular row

The Mac app lifts a featured row into a banner of its own, so "as a regular
row" was wrong for it.

* test(sections): pin the web-only hero row database test in CI

CI runs a database test only when db-pins.txt lists it, so the end-to-end
check of web_only never ran. Split it into a page helper so it also fits
funlen.

* test(sections): build the web-only test's viewer context per call

containedctx refuses a context.Context held in a struct.

* fix(web): shorten the web-only hero tag on the phone row line

"Hero banner · Web only" was cut off mid-word in the phone rows list, whose
one line also holds the row's description. Phones say "Web-only hero".

* test(sections): keep only the web-only tests the testing rules call for

Drop the web adapter and MoreOptions copy tests, and test one client family
per branch in the v2 read wiring.

* fix(sections): apply web_only to the page's banner row only, and send it only on a change

Review fixes:

- The web shows a page's first featured section as the banner and any later
  one as a regular row, so ForClient now drops only that first one when it is
  web-only. A web-only hero that another featured row overtakes goes back to
  the apps.
- A PATCH that makes a row featured stores web_only false unless it sends
  the member, so a value an older server left on a demoted row can't return.
- Changing a row's kind in Edit row keeps its Show in the apps choice.
- The web sends web_only only when a hero row's choice changes, so other
  saves still land on a server that predates the member.

* docs(api): say a web-only section reaches the apps once it isn't the banner

The AdminSection web_only description said the apps never get the section,
but a later featured section is a regular row everywhere.

* fix(sections): tag only the banner web only and keep a stale flag off a re-featured row

The rows list tagged every web-only hero "Web only", though the apps still
get a hero that isn't the page's first. Tag only the page's banner.

A collection's generated hero that an older node demoted kept web_only, and
regenerating it brought the flag back. Clear it when the row becomes the hero,
as an admin update does.

Also correct the migration's header comment and list the web-only database
test with the database contracts rather than the query-budget pins.

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

* chore(api): drop the stale #2940 contract approval

#2940's schema change is on main, so its approval matches no change and
the contract gate fails any branch that changes the OpenAPI document.

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

---------

Co-authored-by: Quick104 <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
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 bug Something isn't working go Pull requests that update go code javascript Pull requests that update javascript code priority: P2 Limited scope, workaround exists, or polish size/M 50–199 added + deleted lines (all files); change volume, not priority.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Admin metadata edit writes any string to an item's match status

2 participants