Repository navigation
fix(apiv2): stop documenting the monitor patch fields as nullable - #3535
Conversation
JSON Schema 2020-12 applies type and enum separately, so a member typed ["string", "null"] whose enum lists only strings still refuses null. ProfileUpdate.max_playback_quality (null removes the ceiling) and AdminItemMetadataUpdate.status (null leaves it unchanged) were documented that way, so a client that validates against /api/v2 refused a null the server accepts. GenerateOpenAPI now adds null to the enum of every nullable component schema after registration, which replaces the per-type transformer on AdminPlaybackHistoryEntry. The pass runs on the document only: Huma's validator accepts null on a nullable schema before it checks the enum, and the registered enum stays as it was, so the 422 message for a bad value doesn't gain a null. DownloadSubscriptionPatchBody.quality is held out through apiv2.NullEnumWithheld: Patch documents it as nullable, but the handler answers 400 for null on every monitor field. The spec lint now fails a nullable enum without null, and fails a NullEnumWithheld entry once its member no longer needs it. Closes Silo-Server#2980
goconst flags a string literal used three times, and the nullable enum rule added the third use of "components.schemas.". The contract doc now says which locations the lint checks: members and array items.
Patch documents every member as nullable, so the updateDownloadSubscription body advertised null for mode, season_numbers, delete_watched, max_storage_bytes, quality and active. The handler answers 400 for null on each of them, and docs/downloads-api.md already says null is rejected. DownloadSubscriptionPatchBody now drops the nullable flag from its members. Requests are handled as before: Huma treats null on an optional member as absent, and the handler's check still answers 400. With quality no longer nullable, the nullable enum exemption has nothing left to hold out, so NullEnumWithheld and its lint branch go. This narrows the request contract and needs a breaking-change approval.
The path only keyed the exemption table, which the previous commit removed.
|
Warning Review limit reachedThis organization requires a seat for paid usage-based reviews, including automatic and on-demand reviews. Ask an admin to assign a seat or enable paid usage-based reviews for users without a seat in Billing. Next included review available in 44 seconds. View limit details
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
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:
|
One request-property-became-not-nullable approval per field of updateDownloadSubscription, ratified in Silo-Server#3535.
|
This changes only OpenAPI schema metadata and generated client types; it does not change the rendered UI or runtime API behavior covered by the visible-change criteria. Add Automated check: Macroscope check run agent (gpt-6-luna). Evidence was not reviewed for correctness. Posted via Macroscope — Visible change evidence |
The nullable enum rule walked only members and array items, so a nullable enum in a oneOf, anyOf or allOf branch or a typed map value passed the lint although the generator covers those places. The rule now has its own walk over all of them.
…tch-nullability # Conflicts: # docs/architecture/api-contract.md # internal/contractspec/lint_test.go
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:
|
|
🤖 Claude Code (claude-opus-5-5) Review summaryReviewed head: Findings: none in this PR's diff. What I checked:
Left for maintainers:
Validated features: none affected. Only the generated User manual: unaffected. The change is to the API document, not to anything the manual describes. Apple/Android parity: not an app PR. No client change is needed, as noted above. Fit: 9/10 · Readiness: 9/10 — ready (once #3534 merges) Fit: the PR makes the published v2 contract match what the server and |
…patch-nullability Silo-Server#3534 merged with its own NullEnumWithheld table, its lint branch, and a check that each entry names a member. This branch removes the table, so the conflicts resolve to this branch's side and the entry check goes too. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Quick104
left a comment
There was a problem hiding this comment.
🤖 Claude Code (claude-opus-5-5)
I merged main into this branch (572d355) now that #3534 has landed. The four conflicts were all in #3534's NullEnumWithheld table, which this PR deletes, so each one resolved to this branch's side. main's version of #3534 had also added a test that each table entry names a real member; that test went with the table. The contract diff against main now reports only this PR's six approved request-property-became-not-nullable changes.
One minor finding, below.
Silo-Server#4064 changes the answer to null on a monitor field from 400 to 422, so the TransformSchema comment and the approval reasons say the handler refuses null rather than naming the status. 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:
|
|
🤖 Claude Code (claude-opus-5-5) Review summaryReviewed head: 34b91af On Branch update. I merged Addressed. The Checked with no finding.
Verification on 34b91af. Validated features. No passed case is affected. I couldn't read the validation board, so I read the User manual. Unaffected. Only the API document changes, and the manual doesn't describe this request's schema. Other clients. silo-apple's Fit: 9/10 · Readiness: 9/10 — ready (assuming CI is green)
|
…patch-nullability Silo-Server#4064 answers null on a monitor field with 422 naming the member and covers all six fields, quality included, in its own transport test, so the transport test takes main's side and this branch no longer lists {"quality":null} among the 400 cases. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…patch-nullability
The contract check reads Silo-Server#3535's approvals in the merge base as stale for this branch, as earlier pull requests have found. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Silo-Server#3535 is on main, so its six breaking-change approvals no longer match a change between this branch and its base, and the contract gate fails on them as stale. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The six updateDownloadSubscription entries were approved in #3535 and match no change against the current base, so the contract gate fails every pull request until they go. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s language (#4189) * fix(watch-providers): say which action failed and why, in the viewer's language Watch-provider toasts showed only the raw failure text: a request's English developer message for a timeout, a failed fetch, or a proxy page, and the generic conflict line in other languages when connecting before the code was approved. Each failure now names the action as the toast title and explains it below in the interface language. The poll answer now tells its outcomes apart: an expired code is device_login_expired (410), an authorization already completed is already_linked, a declined one is not_permitted, and a code not approved yet stays conflict with an English detail a person can act on. A plugin's EXPIRED and DENIED answers map to the same outcomes instead of a 500. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(watch-providers): answer a repeated poll with the connection and explain a declined one Finishing a device authorization again after its first answer was lost now returns the connection that answer created, instead of an error while the card still shows "not connected". A used code with no connection left reads as expired. A declined authorization gets its own line on the web rather than the shared "That isn't allowed." text, and a failure to save the provider's pending challenge reads as a server error rather than "approve the code first". Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(watch-providers): report a failed connection read on a repeated poll as a server error A completed session's retry read the connection and treated any failure as an expired code; a database or provider status failure now answers as itself. Co-Authored-By: Claude Opus 5.5 <[email protected]> * chore(apiv2): drop breaking-change approvals that already merged The six updateDownloadSubscription entries were approved in #3535 and match no change against the current base, so the contract gate fails every pull request until they go. Co-Authored-By: Claude Opus 5.5 <[email protected]> * chore(i18n): sync translations from release 2026.11.14-295ae4b Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(watch-providers): drop a device code the poll says can't finish An expired, used, declined, or unknown code (410, 403, 404) stayed on the card with its "I've entered it" button, so selecting it again repeated the same refusal. Clear it like Cancel does so the card offers Connect again. A code not approved yet (409) stays. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
…it (#4195) * fix(catalog): keep durable provider IDs in step with an admin's ID edit The admin metadata edit stored an IMDb, TMDB or TVDB ID exactly as typed and left the item's durable provider ID behind. A padded ID ("550 ") missed exact lookups, and a corrected or cleared one kept the old durable ID, which lookups, AttachTMDBID's conflict check and a refresh's ID seeding read; a refresh restored a cleared ID from it. The v2 PATCH now stores each ID the way a refresh stores it: trimmed, IMDb in lowercase, a TMDB URL slug dropped. It answers 422 at the member for a value that is no ID of its provider. On a movie or series, the same transaction replaces or removes the durable row for each edited provider. An ID another item already holds stays on the column only, as before. Co-Authored-By: Claude Opus 5.5 <[email protected]> * chore(apiv2): clear breaking-change approvals that have merged The six updateDownloadSubscription entries merged with #3535. An approval lives only on the pull request that needs it, so the next pull request removes it. Co-Authored-By: Claude Opus 5.5 <[email protected]> * perf(catalog): let the edited ID's holder check use the provider ID key Wrapping held.provider in lower() kept the check from using the (provider, provider_id, item_type) unique key, so every edited ID scanned media_item_provider_ids. That key compares the provider exactly, so an exact match is also what decides whether the insert would conflict. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(catalog): lock the item before replacing its provider IDs A curator's ID edit locks the item FOR UPDATE, then deletes its provider row. A standalone ReplaceByContentID (book enrichment, a legacy refresh) deleted the item's rows first and then waited on that lock for its inserts, so the two deadlocked. It now locks the item first, as the edit does, and the two queue instead. The test's lock-wait check now looks only at this database and the statement it expects to block, since CI runs packages against separate databases on one server. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(catalog): leave the durable row alone when an edit resends an ID An edit form resends IDs the item already has. lockCuratedProviderIDs treats those as unchanged and skips its checks, so the durable-ID sync now skips them too and writes only IDs the edit actually changes, compared the same way (trimmed, any case). Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(metadata): lock the item before a drift repair replaces its provider IDs An admin's ID edit now locks the item and then deletes the edited provider's row. The startup provider-ID drift repair deleted the item's rows first and needed the item for its inserts' foreign-key check, so an edit and a repair of the same item could deadlock and fail the edit. The repair now locks the item first, as ReplaceByContentID does. Co-Authored-By: Claude Opus 5.5 <[email protected]> * refactor(catalog): reuse contentid's provider names in the ID-edit sync Drops the package's second copy of the tmdb, imdb and tvdb names, keeps each stored ID beside its provider instead of in a map, and corrects the sync's comment now that ReplaceByContentID locks the item. The admin API doc now says a resent, unchanged ID leaves the durable ID alone. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(metadata): lock a skeleton before a rebind moves its provider IDs An automatic rebind moved the skeleton's provider rows and only locked the skeleton at its final delete. An admin's ID edit locks the item and then deletes one of those rows, so the two could deadlock and fail the edit or the refresh. The rebind now locks the skeleton after its files and before its provider rows, the order the edit and refresh use. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(metadata): skip a drift repair whose item changed while it waited The repair reads an item's ID columns in its batch query and only locks the item later. When it waited behind an admin's ID edit, it then wrote the IDs it had read before the edit over the edited durable ID. It now re-reads the columns under the lock and leaves the item for the next run when they changed, or when the item is gone. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(metadata): lock and re-check the item before moving a provisional claim The drift repair's provisional-owner branch locked only the owner, then deleted the drifted item's provider rows and wrote the IDs it had read in its batch. Like the clean-insert branch before 7497947, it could deadlock with an admin's ID edit of that item, or write back the IDs the edit replaced. Both branches now share one check that locks the item first and skips it when its IDs changed; the owner is locked after it, the order the edit takes the item and the holders of its IDs. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(metadata): skip a provisional owner that lost the drifted ID The repair picks a provisional owner before it locks anything, and after 53718d2 it can wait on the drifted item first. It then deleted all of the owner's provider rows even when an edit had moved the owner off the ID in the meantime. It now checks, under the owner's lock, that the owner still holds one of the IDs, and leaves the owner for the next run otherwise. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
Problem
Related issue: #2980
Validation tasks: none (only the generated
/api/v2document changes; the server handles requests exactly as before)#3534, which this built on, has merged, and
mainis merged into this branch, so the diff againstmainis this change alone.The
/api/v2document says all six fields of the download monitor edit (PATCH /api/v2/downloads/subscriptions/{id}) acceptnull, but the server refusesnullon every one of them (since #4064, with a422 validation_failednaming the field). A client generated from the document can send a request the server will always refuse. This change documents those fields as not nullable, which is what the server anddocs/downloads-api.mdalready say.The fields are
mode,season_numbers,delete_watched,max_storage_bytes,qualityandactiveonDownloadSubscriptionPatchBody. They're nullable in the document becausePatch[T].Schemamarks every member nullable, whileupdateDownloadSubscriptionrefusesnullfor all of them.Approach
DownloadSubscriptionPatchBodygets aTransformSchemathat drops the nullable flag from its members. No otherPatchbody refusesnullon a member, so I kept the fix on this one type rather than adding a second presence-aware type next toPatch. Requests behave the same: Huma treatsnullon an optional member as absent, so the handler's own check still refuses it. The transport test from #4064 coversnullon all six fields,qualityincluded.With
qualityno longer nullable, #3534's exemption for it (apiv2.NullEnumWithheld) has nothing left to hold out, so the table and its lint branch go too.This narrows the request contract, so
contracts/api/v2/breaking-approvals.jsoncarries onerequest-property-became-not-nullableapproval per field. First-party clients don't sendnullhere: silo-apple'sUpdateSubscriptionRequestis a synthesizedEncodablestruct of optionals, which leaves nil fields out, and silo-android and the web app don't call this operation.The web types change to match: the six fields lose
| null. Nothing inweb/srcoutside the generated types uses them.Validation
The contract checks ran on
3d377b78a. Theinternal/apiv2tests ran on3c727c39e, whoseinternal/apiv2code is the same; later commits only add the approvals and #3534's lint change.make apiv2-openapi,make verify-apiv2-openapi,make apiv2-web-typesandmake verify-apiv2-web-types: current.make verify-apiv2-contractagainstmain: the lint passes, and the diff reports the sixrequest-property-became-not-nullablechanges onupdateDownloadSubscription, each approved, plus fix(apiv2): list null in the enum of nullable request members #3534's non-breaking enum additions.make verify-apiv2-fixtures, theinternal/contractspectests and focusedinternal/apiv2tests, including the monitor transport test: pass.go veton both packages, andgolangci-lint --new-from-merge-baseoninternal/contractspec: clean.make lint-changedforinternal/apiv2,make test-goand the web checks, runs on CI.Evidence
Evidence: none, no user-visible change
No screen changes. What clients see is the
GET /api/v2/openapi.jsonresponse, which serves the committedcontracts/api/v2/openapi.jsonbytes.DownloadSubscriptionPatchBody, trimmed totypeandenum:Before and after
Before (
mainat2d5f22e7d):After (this branch at
3d377b78a):Risks
A breaking change to the request contract before the 1.0 lock, approved per field in
breaking-approvals.json. A third-party client that sendsnullfor one of these fields is already refused, so only its generated types change. There's no runtime change.Checklist
AI Disclosure
Note
Mark
DownloadSubscriptionPatchBodypatch fields as non-nullable in apiv2TransformSchemamethod that setsNullableto false on all six optionalDownloadSubscriptionPatchBodyproperties in download_subscription_mutations.go, so generated OpenAPI and TypeScript schemas drop null from those typesapiv2.NullEnumWithheldexception map and its special handling inadmitNullInNullableEnumsandlintNullableEnum; the lint now rejects every nullable enum that omits null, and OpenAPI generation adds null to all nullable schema enumsqualityenum in the generated TypeScript schema changes from string-or-null to string; clients previously sending explicitnullfor these patch fields may now fail validationMacroscope summarized 34b91af.