Repository navigation
fix(apiv2): reject an unknown match status in the admin metadata edit - #2940
Conversation
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
|
Warning Review limit reachedYou'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. View limit details
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 |
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:
|
|
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.
Automated check: Macroscope check run agent (gpt-6-luna). Evidence was not reviewed for correctness. Posted via Macroscope — Visible change evidence |
|
Major change: #1210 C1 (Server) and #1211 C1 (Web admin). The v2 metadata PATCH now rejects non-match The #1210/#1211 C2 lock/rescan checks do not set Suggested fix: No diff; retain Automated check: Macroscope check run agent (gpt-6-luna). No validation was performed. Posted via Macroscope — v1 validation impact |
|
The Suggested fix: - Validation tasks: changes #1210 C1 and #1211 C1 (the series Status edit both report as failing on `main`)
+ Validation tasks: noneAutomated check: Macroscope check run agent (gpt-6-luna). No validation was performed. Posted via Macroscope — v1 validation impact |
|
The line now reads
|
Quick104
left a comment
There was a problem hiding this comment.
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"` |
There was a problem hiding this comment.
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.
Review summaryReviewed head: The change does what it says. Checked
Findings
For the maintainers to settle
Validated features No passed case on the v1.0 board reaches this diff. #1210 C1 and #1211 C1 are still 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 |
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]>
* 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]>
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
matcheddrops out of search indexing, semantic coverage, enrichment and local sidecar queries until a refresh resets it. This change makesPATCH /api/v2/admin/items/{id}/metadataaccept onlypending,matchedorunmatchedforstatusand removes the dialog's select.Approach
statuson the v2 request is now a closed enum. Any other value fails Huma validation with422 validation_failedbefore the service runs, asdocs/architecture/api-contract.mdrequires for request enums.nullstill leaves the value unchanged. I kept the field instead of removing it because the server already treatsstatus: "matched"as a manual match (it clears the admin's ignore).ambiguousis 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, socontracts/api/v2/breaking-approvals.jsoncarries a pre-lock approval for it. The OpenAPI artifact, the generated web types anddocs/admin-catalog-api.mdare 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/v1uses the same service and still accepts any string. silo-apple and silo-android don't send this field. jellycompat has no equivalent write.Validation
"Ended"gets 422 without reaching the service, and a valid status andnullpass. It failed onmainwith a 200."Ended"returned 422 and the stored status didn't change.matchedandunmatchedwere stored, andnullleft the status alone.internal/apiv2andinternal/contractspectests,make lint-changedand gofmt pass.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.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/v2handler, run in-process with the handler test's metadata service fake (the 422 comes from request validation, before the service is called). Before ismainatbe6527e50; after is this branch ata40a6b2a6.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
AI Disclosure