Skip to content

[bug] Admin metadata PATCH returns 500 for a blank date and silently ignores null on fields it can't clear #2277

Open

Description

@Quick104

What happened

PATCH /api/v2/admin/items/{id}/metadata doesn't validate two kinds of input the v2 contract says it should reject:

  • An empty or malformed date string in release_date (or a season or episode air_date) returns 500 internal_error. The value goes to a PostgreSQL date column as raw text, and the database rejects it.
  • null on a member that can't be cleared, such as title, year, or genres, returns 200 and changes nothing. The OpenAPI schema marks every member of this request nullable, so a client can't tell which members clear on null and which ignore it.

Steps to reproduce

  1. As an admin, send PATCH /api/v2/admin/items/{id}/metadata for a movie with the body {"release_date":""}, then {"release_date":"not-a-date"}. Both return 500.
  2. Send {"title":null}. It returns 200 and the title is unchanged.

Expected behavior

A malformed or empty date is a 422 validation_failed naming the member. Per the PATCH rule in docs/architecture/api-contract.md, null on a member that can't be cleared is also a 422 validation_failed naming the member, and the schema marks only the clearable members nullable.

Silo version / commit

main at cae87c893, and the branch of #2275, which doesn't change these code paths.

Deployment

A Silo dev deployment (disposable sandbox).

Area

API

Clients affected

  • Web UI
  • Android
  • iOS/tvOS/macOS
  • Jellyfin-compat client (Infuse, Findroid, ...)
  • Other/not client-specific

The web dialog sends null instead of "" for empty dates and never sends null for the other members, so it doesn't hit either case. Third-party v2 clients can.

Relevant logs

no logs available

Technical notes

  • The repositories bind release_date and air_date with addString (internal/catalog/item_repo.go, season_repo.go, episode_repo.go), and the request schema has no date format, so nothing checks the value before PostgreSQL does.
  • Rejecting null on the other members means dropping nullable:"true" from them in AdminItemMetadataUpdate and calling rejectNonNullableNulls with the clearable set, as other v2 PATCH handlers do. Narrowing a request schema is a breaking change for make verify-apiv2-contract, so it needs a breaking-change approval before 1.0 locks v2.
  • fix(metadata): clear a rating or date when an edit sends null #2275 makes null clear the ten nullable members of this request. This fix should follow it, since both change the same request type.

Validation reference

None. #1210 and #1211 cover metadata editing; neither has a passed case.

AI harness

Claude Code (running in T3 Code)

AI tool(s)

Claude Code, GitHub CLI

AI model(s)

claude-opus-5-5

AI involvement

AI-assisted

Independent or adversarial review

Found by claude-opus-5-5 and claude-sonnet-5-5 review subagents in the pre-PR review of #2275, then confirmed against the source and on a dev deployment.

Confirmations

  • I searched open and recently closed issues and pull requests, and this is not already reported
  • I reproduced this myself on a real deployment
  • Any logs provided are raw apart from marked redactions and are not AI-summarized; if none were available, I said so above

Source: found in review of #2275

Activity

  1. added
    bug
    on Oct 11, 2026
  2. added
    api-v2
    priority: P2
    on Oct 11, 2026
  3. Tobechukwu-Njoku commented on Oct 20, 2026

    @Tobechukwu-Njoku
    Contributor

    I'll take the first half of this: a blank or malformed release_date, first_air_date, last_air_date or air_date will get 422 validation_failed naming the member (dates must be YYYY-MM-DD, as the API contract says), checked in the handler before anything reaches PostgreSQL, with tests. null still clears these four.

    I'm leaving the second half (rejecting null on members that can't be cleared) out: dropping nullable from those members narrows the v2 request schema, which needs a maintainer's breaking-change approval first. I'll note that in the PR.

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