Repository navigation
fix(apiv2): answer null on a monitor field with 422 naming it - #4064
Merged
Quick104 merged 1 commit intoNov 13, 2026
Merged
Conversation
PATCH /api/v2/downloads/subscriptions/{id} refused an explicit null on
any monitor field with 400 malformed_request and no member name. The v2
PATCH rule in api-contract.md makes null on a member that cannot be
cleared a 422 validation_failed naming the member, as updateProfile
answers. The handler now checks the raw body with the same helper, so
each null member is named at body.<member>.
Closes Silo-Server#3720
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:
|
Contributor
Closed
3 of 4 tasks
Contributor
Maintainer reviewReviewed head: Fit: 9/10 · Readiness: 9/10 — ready
What I checked
Left for the maintainers
Validation, manual, and clients
🤖 Claude Code (claude-opus-5-5) |
4 tasks done
Quick104
added a commit
to blurbery/silo-server
that referenced
this pull request
Nov 13, 2026
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]>
4 tasks done
Quick104
added a commit
to blurbery/silo-server
that referenced
this pull request
Nov 13, 2026
…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]>
rangoDJ
added a commit
to rangoDJ/silo-server
that referenced
this pull request
Nov 13, 2026
Silo-Server#4064 merged as ce41061, a squash of ab30ed6, which this branch was built on. The two conflicted in the subscription handler and its test; this branch's side keeps Silo-Server#4064's null check and adds the bounds check. main's copy of the files equals ab30ed6. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Quick104
added a commit
that referenced
this pull request
Nov 14, 2026
) * fix(apiv2): list null in the enum of nullable request members 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 #2980 * refactor(contractspec): name the component schema prefix once 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. * fix(apiv2): stop documenting the monitor patch fields as nullable 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. * refactor(apiv2): drop the unused schema path from the nullable enum pass The path only keyed the exemption table, which the previous commit removed. * chore(apiv2): approve the monitor patch nullability change One request-property-became-not-nullable approval per field of updateDownloadSubscription, ratified in #3535. * fix(contractspec): check nullable enums wherever the generator adds null 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. * docs(apiv2): describe the monitor null refusal without its status code #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]> --------- Co-authored-by: Quick104 <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Closes #3720
Related issue: #3535
Validation tasks: none
Other clients: Apple N/A (leaves unset fields out of this request, so it never sends
null); Android N/A (doesn't call this operation); Roku N/A (same)PATCH /api/v2/downloads/subscriptions/{id}answered an explicitnullon any monitor field (mode,season_numbers,delete_watched,max_storage_bytes,quality,active) with400 malformed_requestand no member name. The v2 PATCH rule indocs/architecture/api-contract.mdmakesnullon a member that can't be cleared a422 validation_failednaming the member, which is whatupdateProfileanswers.Dependencies and merge order: no code dependency, and it builds on
main. #3535 (open) edits the same handler's schema and adds{"quality":null}to the same test list, which this PR replaces. Whichever merges second needs a small conflict fix indownload_subscription_mutations_test.go. #3535's comment onTransformSchemasays the handler refuses null "with 400", which would then read 422.#4074 (#4068) builds on this branch and should merge after it.
Approach
ProfileUpdateInputdoes, and the handler checks it withrejectNonNullableNulls, the helperupdateProfileuses. No monitor field can be cleared, so everynullmember gets an error atbody.<member>, sorted by location.max_storage_bytes: -1still answers 400.Validation
gofmt,go vet, and the changed-package lint are clean.go testpasses forinternal/apiv2andinternal/contractspec, andmake verify-apiv2-openapireports the document current.TestSubscriptionMutationTransportnow expects 422 naming the member fornullon each of the six fields, and both members for a body with two nulls. With the old null check put back, it fails withstatus = 400, want 422.make test-go.Evidence
No visible layout change. The evidence is the response body, from the transport test's handler on WSL2 (Ubuntu,
go1.26.4 linux/amd64),mainat0387303d9and this PR atab30ed69d. Theinstancemember is left out.Before (
main):After (this PR):
Risks
nullhere, and/api/v2isn't locked yet.Checklist
AI Disclosure
🤖 Generated with Claude Code
Note
Return 422 naming the field when a null value hits a monitor field in apiv2
PATCH requests to download subscriptions previously returned a generic malformed-request problem when a monitor field was null. The handler in download_subscription_mutations.go now keeps the raw request body on
DownloadSubscriptionPatchInputand passes it torejectNonNullableNulls, which reports the offending body members by name.Transport tests cover null in each monitor field and multi-field cases, asserting locations are reported in order (e.g.
body.mode,body.quality).Macroscope summarized ab30ed6.