Repository navigation
fix(apiv2): declare the statuses operations already return - #3046
Conversation
Several v2 handlers answer statuses their operation registrations never declared, so the published contract and the generated web types left them out: - 409 on the recommendation triggers, runAdminTask, cancelAdminTask, createAdminUser, impersonateAdminUser, cancelAdminHistoryImportRun, createAdminHistoryImportRun, createAdminHistoryImportMapping, deleteAdminHistoryImportSource, plugin repository update and delete, redetectAdminEpisodeIntro, deleteAdminCollection and the five manual-membership admin collection operations. - 501 capability_unsupported on listCatalogItems, queryCatalogItems, queryCatalogLetters, listAudiobookGroups, getCatalogSearchCapabilities and createAdminUser. - 403 on listPersonalAPIKeys, which refuses API-key callers. The implied-status rule added 429 only for gated classes, so public operations that name a rate-limit bucket (device login start, poll and cancel, setup, signup and the autoscan webhook) never documented the 429 their limiter answers. ImpliedStatuses now adds 429 for any operation with a bucket. The X-Silo-Client-Family text on the effective settings reads now says the header is optional, as the server treats it.
|
Warning Review limit reachedThis review ran on the open-source allowance, not this organization's plan, because the pull request author doesn't have an assigned seat. Waiting won't change this — ask an organization admin to assign them a seat, or add seats in Billing if every seat is already assigned, then retry. Next included review available in 16 minutes. View limit details
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 server behavior and rendered UI are unchanged; this PR only updates OpenAPI declarations and generated TypeScript types. Please add Suggested fix: add the line above under Automated check: Macroscope check run agent (gpt-6-luna). Evidence was not reviewed for correctness. Posted via Macroscope — Visible change evidence |
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:
|
|
No actionable findings at Fit: 10/10 · Readiness: 9/10 — ready This fixes an existing public-contract gap at the operation registrations and shared status generator. Each added status matches a handler path. The OpenAPI diff adds 34 responses across 33 operations and corrects the client-family description on two operations. Request handling, authorization, success shapes, and required parameters retain their existing behavior. Validation:
Validated features: the board and Collections server task #193 show no passed behavior changed by this diff. Those recorded server results are agent API checks; human acceptance remains outstanding. The validation helper could not read the current records reliably, so the board and issue records were read directly. No formal check covers the changed files. Validation tasks: none Apple, Android, and web decode problem responses generically; the additions require no client changes. Jellyfin behavior is unaffected. The settings API guide already documents the optional client-family behavior. The user manual's API and rate-limit guidance remains accurate, so no manual issue is needed. Independent review: three Codex source reviews, a final sweep, and one Claude review found no defects. No fix commits were needed. AI disclosure: reviewed through T3 Code with the Codex harness using |
Problem
Related issue: N/A
Validation tasks: none
The v2 contract leaves out statuses that some handlers already return, so anything generated from
contracts/api/v2/openapi.json, including the web'sweb/src/api/v2types, doesn't know those responses exist. A busy recommendation trigger answers 409, a rate-limited Quick Connect poll answers 429, and catalog browsing answers 501 when the user store can't run the query, but none of those operations list the status. This change declares them on the registrations and regenerates the contract and the web types. It only adds to the contract.What was missing:
triggerAdminRecommendation*operations (the job is already running here or on another server);runAdminTaskandcancelAdminTask(the task is already running, or isn't running);createAdminUser(username or email taken, or an access group on a server without access groups) andimpersonateAdminUser(already impersonating, or impersonation not configured);cancelAdminHistoryImportRun(job_not_cancelable),createAdminHistoryImportRun(a run is already active, or the source is disabled or has no admin token),createAdminHistoryImportMapping(the external user is already mapped on that source) anddeleteAdminHistoryImportSource(mappings still reference it);updateAdminPluginRepositoryanddeleteAdminPluginRepository(managed repository);redetectAdminEpisodeIntro(local detection can't run);deleteAdminCollection(a page section still uses it);getAdminCollectionItems,getAdminCollectionItemsOrder,reorderAdminCollectionItems,addAdminCollectionItemandremoveAdminCollectionItem(collection_not_manualfor a collection that isn't manual).startDeviceLogin,pollDeviceLogin,cancelDeviceLogin,setupServer,signupandreceiveAutoscanWebhook.capability_unsupportedon:listCatalogItems,queryCatalogItems,queryCatalogLettersandlistAudiobookGroups(the user store or search index can't serve the query);getCatalogSearchCapabilities(the search index result window is outside what this build can page);createAdminUser(a default profile on a user store that can't create it in the same transaction).listPersonalAPIKeys, which refuses API-key callers.The
X-Silo-Client-Familytext onlistEffectiveSettingsandresolveEffectiveSettingsalso said the header is required when a requested key hasprofile_clientscope. The server treats it as optional and skips that layer when it's absent, asdocs/settings-api.mdalready says, so the parameter text now says that too.Approach
Most of these are an
Errorsentry on the registration, the way the siblings that already declare theirs do it (resetAdminRecommendationEmbeddings,updateAdminUser,refreshAdminEpisodeMarkers). The five manual-membership collection operations share a smallmanualMembershipOperationhelper.The 429 gap came from the implied-status rule.
ImpliedStatusesadded 429 only for gated classes, butgateChainruns the per-endpoint limiter for a public operation that names aRateLimitBucket, so those operations could answer 429 without documenting it.login, the password resets, the public invitation operations andgetDeviceLogingot around that by listing 429 themselves.ImpliedStatusesnow adds 429 for any operation with a bucket; the six operations above are the only ones whose contract changes. The spec lint ininternal/contractspeccan't see buckets because the document doesn't carry them, so it passesfalse, and the check lives ininternal/apiv2instead. No raw registration names a bucket, soRawImpliedStatusesis unchanged.TestBucketLimitedPublicOperationsDocument429walks every registered public operation, asksgateChainwhether it runs a limiter, and requires a documented 429. On main it fails for exactly those six operations.Web code needs no change: it already branches on the runtime status for collection delete, plugin repository writes, impersonation and Quick Connect, and the regenerated types only add response entries. silo-apple and silo-android hand-write their v2 models and decode problem documents generically, and the vendored fixtures don't change, so neither needs a follow-up. jellycompat isn't affected.
Left out of this PR:
AdminDashboardLayout.layoutandupdated_atare null when no layout is saved, but the schema marks them non-nullable. Declaring them nullable is the fix, but the contract diff classesresponse-property-became-nullableas breaking, so I've left it for a maintainer to decide whether to approve it.addCollectionItem,removeCollectionItemandreorderCollectionItemsalso answer 409collection_not_manual, like their admin counterparts here. fix(collections): bound count queries and retain recovery access #2728 rewrites theaddCollectionItemregistration, in a hunk that covers the other two, so I've left all three to follow it rather than collide.limitclamp (50) against the contract's maximum of 100, downloads answering 400 where 422 is documented, Go transport schema names, and the v2 marker writes demo gate, which another PR fixes.Validation
All on commit
43748896e, rebased on upstream maina0f8c547f:go vet ./internal/apiv2/ ./internal/contractspec/: clean.go test -count=1 ./internal/apiv2/: pass. The new test fails on main for the six operations and passes here.go test -count=1 -run '^TestCommittedArtifactMatchesRouter$' ./internal/apiv2/: pass.make verify-apiv2-openapi,make verify-apiv2-fixturesandmake verify-apiv2-web-types: current.make apiv2-fixtureschanged nothing, since the fixtures are response bodies.BASE_REF=upstream/main make verify-apiv2-contract: spec lint passes; 34 changes, allinfo(response-non-success-status-added), none breaking, no approval added.make lint-changedand the rest of the full gate (Go and web suites, web lint and build).d6dd0aa43only rewords two comments the CImisspelllint flagged. Checked withgolangci-lint run --enable-only misspell --new-from-merge-base upstream/main ./internal/apiv2/(0 issues),gofmt,go vetandmake verify-apiv2-openapi.Evidence
Evidence: none, no user-visible change
Server behaviour and every screen are unchanged; only the published contract and the generated web types change. For reference, the
responseskeys incontracts/api/v2/openapi.jsonfor two operations, before (upstream maina0f8c547f) and after (this branch):Each new entry is the shared problem response, for example:
Surface and build: the artifact
make apiv2-openapigenerates, from upstream maina0f8c547fand from this branch at43748896e.Risks
None at runtime: handlers behave as before, and only the document and the generated web types change. Other open PRs that regenerate
openapi.jsonwill need to regenerate again after this lands, or this one after them. #2728 adds a line beside theaddAdminCollectionItemregistration, so whichever lands second has a one-line conflict there.Checklist
AI Disclosure
createAdminUserandgetCatalogSearchCapabilities, and broader wording on two comments. The personal collection membership 409s are listed under "Left out" because of fix(collections): bound count queries and retain recovery access #2728. I keptRawImpliedStatusesand the explicit 429s on login and the password resets unchanged: no raw operation names a bucket, the new test covers raw paths too, and the explicit 429s produce no contract change.Note
Declare existing Conflict, Forbidden, and Not Implemented responses in apiv2 operation docs
ImpliedStatusesin document.go with a rate-limited flag so bucket-limited public operations now document a 429 Too Many Requests response, verified by a new test in document_test.go.manualMembershipOperationhelper in admin_collections.go and clarifies the client-family header as optional in effective settings models.Macroscope summarized d6dd0aa.