Skip to content

[bug] v2 OpenAPI rejects null on nullable enum request fields #2980

Closed

Description

@Quick104

What happened

In the published /api/v2 OpenAPI document, a nullable request field that also carries an enum gets "type": ["string", "null"] and an enum without null. In JSON Schema 2020-12, enum applies on its own, so a schema validator rejects null for these fields, but the server accepts it and documents what it does.

On main:

  • ProfileUpdate.max_playback_quality: described as "Playback ceiling; null removes it", enum: ["1080p", "2160p"].
  • DownloadSubscriptionPatchBody.quality: enum: ["original", "20mbps", "10mbps", "5mbps", "2mbps", "1mbps"].

Open PR #2940 adds a third: AdminItemMetadataUpdate.status ("null leaves it unchanged"), enum: ["pending", "matched", "unmatched"].

A client that validates requests against the schema, or a generator that builds strict types from it, refuses a null the API accepts. The bundled web types aren't affected, because openapi-typescript adds | null from type.

Steps to reproduce

Not reproduced on a deployment. Checked against contracts/api/v2/openapi.json:

import json, jsonschema
s = json.load(open("contracts/api/v2/openapi.json"))["components"]["schemas"]
jsonschema.Draft202012Validator(s["ProfileUpdate"]["properties"]["max_playback_quality"]).validate(None)
# jsonschema.ValidationError: None is not one of ['1080p', '2160p']

Expected behavior

The schema of a nullable enum field accepts null: null is in its enum, or the field is expressed as anyOf of the enum and {"type": "null"}.

Silo version / commit

main at 19f59ef.

Deployment

N/A (published contract artifact).

Clients affected

Third-party clients and generators that validate against or build types from /api/v2 OpenAPI. First-party clients not known to be affected.

Relevant logs

No logs available.

Technical notes

The general fix probably belongs in the v2 schema generation in internal/apiv2: when a field is nullable and has an enum, add null to the enum. Then regenerate contracts/api/v2/openapi.json and the web types. Adding null to a request enum should be a non-breaking change in the contract diff. This fix changes the same status lines as #2940, so it should follow that PR.

AI disclosure

  • Harness: Claude Code (via T3 Code)
  • Tools: Claude Code; Codex CLI (cross-provider review)
  • Models: claude-opus-5-5; gpt-6.1-sol
  • Involvement: Found and written by AI during a review; checked against the schema with a JSON Schema validator
  • Independent review: gpt-6.1-sol reported it; claude-opus-5-5 confirmed it with the snippet above

Source: found in review of #2940

Activity

  1. added
    bug
    on Oct 23, 2026
  2. added
    api-v2
    priority: P2
    on Oct 23, 2026
  3. blurbery commented on Nov 5, 2026

    @blurbery
    Contributor

    I've left DownloadSubscriptionPatchBody.quality out of #3534. It's the opposite case: updateDownloadSubscription answers 400 for null on all six monitor fields, so the enum without null is the one part of that schema that matches the server. The actual bug is that Patch[T] documents those fields as nullable at all. Fixing that narrows the request contract and needs a breaking-change approval, so I'd rather do it separately.

  4. added a commit that references this issue on Nov 9, 2026
    6685aab
  5. added a commit that references this issue on Nov 14, 2026
    e39b8ea
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    api-v2bugpriority: P2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions