Skip to content

fix(metadata): clear a rating or date when an edit sends null - #2275

Merged
Quick104 merged 1 commit into
mainfrom
fix/issue-2238
Oct 11, 2026
Merged

Quick104 merged 1 commit into
mainfrom
fix/issue-2238

Conversation

@Quick104

@Quick104 Quick104 commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Closes #2238
Related issue: N/A
Validation tasks: unblocks #1211 C1; touches #1210 C1 (not yet run)

An admin who empties a rating or date in Edit Metadata and saves sees the old value come
back after a reload. The dialog sends the cleared field as null, but the server treated
null like an omitted field and left the column alone. The save still recorded the
field's lock, so a later metadata refresh wouldn't correct the value either. This change
makes an explicit null clear the field.

Approach

PATCH /api/v2/admin/items/{id}/metadata now tells null apart from omission for the
ten members whose columns are nullable: the four ratings, release_date,
first_air_date, last_air_date, air_time, air_timezone, and air_date. Huma
decodes both to a nil pointer, so the handler reads the raw body to find the null
members, as the account policy PATCH does. Switching the request to Patch[T] would
split it from the type v1 shares. catalog.MetadataUpdate carries the cleared fields in
a Clear list, and the item, season, and episode repositories set their own columns to
NULL. This follows the contract's PATCH rule. The schema already marked these members
nullable, so the OpenAPI document changes only in descriptions.

Clearing a rating also deletes the item's stored per-source score for that source
(imdb, tmdb, rt_critic, rt_audience) in the same transaction. Metadata plugins
such as MDBList store those rows, and the title page's ratings list falls back to them
when the column is empty, so without this the cleared rating would still show there. The
existing trigger clears the TMDB vote count copied from the tmdb row. Clearing an
episode's air date recomputes the series air dates, as an air-date edit already does.

null on any other member still leaves the value unchanged, and frozen v1 still treats
null as omission. The web dialog already sent null for these fields. Its only change
is sending null instead of "" for a cleared air timezone; the server accepts either.
Neither the Apple nor the Android app calls this endpoint, and jellycompat has no
item-update endpoint, so no client follow-up is needed. The user manual already says to
change a field and save, so it needs no update.

Two scenario acceptance tests asserted that null preserves the air timezone and season
and episode air dates. Their null cases now expect those fields cleared, and the
item-curation case is renamed from null_preserves to explicit_nulls.

Validation

  • Reproduced on a disposable Silo dev deployment built from main: clearing IMDb, then the release
    date, in the dialog returned 200, and both values came back after a reload, at desktop
    and phone width. On the same sandbox rebuilt from this branch, with the same item, data,
    and steps, both stayed cleared and the stored row held NULL.
  • On the fixed sandbox over the API: clearing IMDb and TMDB removed them from the title
    page's ratings and deleted the plugin-stored imdb and tmdb rows and the TMDB vote
    count, leaving a plugin's own letterboxd row. Clearing the air date of a series'
    latest aired episode moved the series' last air date back to the previous episode.
    {"title": null} left the title unchanged.
  • New database test for item, season, and episode clears, the rating-row deletion, and the
    series air-date recompute, listed in scripts/ci/db-contracts.txt. The extended v2
    transport test covers which null members become clears. Both fail with clearing
    disabled. A new dialog test covers sending null for cleared fields.
  • make test-db-contracts against a fresh migrated PostgreSQL 18 + pgvector database:
    all 131 pass.
  • go build, gofmt, go vet, and make lint-changed (golangci-lint v2.12.2) are
    clean.
  • make test-go passes except TestAdminResourceCapabilitiesAndScope and two
    jellycompat Dolby Vision playback tests, which fail the same way on main on the macOS
    machine used here.
  • Web lint, format check, build, budget check, and the dialog tests pass.
  • verify-apiv2-openapi, verify-apiv2-web-types, verify-apiv2-contract,
    verify-apiv2-fixtures, verify-scenario-catalogs, the router artifact test, route
    inventory, local paths, and case collisions pass.
  • The item and child curation scenario suites (not run in CI): the two updated null cases
    pass. Three other cases in those suites (empty_clears, exact_item,
    episode_identity) fail the same way on main, because their expectations predate the
    derived search vectors and series air dates.

Evidence

Desktop and phone-width captures of the Edit Metadata dialog before and after, recordings
of both desktop runs, the API checks, and the test results.

Evidence: https://evidence.siloserver.org/r/silo-server/issue-2238/

Risks

  • A v2 client that sends null for one of the ten members to mean "leave it" will now
    clear the field. The web dialog is the only caller and sends null only for fields the
    user emptied.
  • Clearing an item's TMDB rating removes its tmdb source row and vote count, so the
    item drops out of the vote-ranked discovery rows. The web editor's rating lock keeps a
    refresh from restoring it until the field is unlocked.
  • No migration.

Follow-ups found in review, both present on main: #2277 (a blank date returns 500, and null on members that can't be cleared is silently ignored; it should follow this PR) and #2278 (three other cases in the curation scenario suites have stale expectations).

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.
  • The Evidence section shows every change a user can see, or says there is none.

AI Disclosure

  • Harness: Claude Code, running in T3 Code
  • Tool(s): Claude Code, GitHub CLI, golangci-lint, Playwright (headless Chromium capture)
  • Model(s): claude-opus-5-5 (implementation and review subagents), claude-sonnet-5-5 (review subagents)
  • Involvement: Fully AI-generated, human verified
  • Adversarial review: Codex (gpt-6.1-sol, xhigh reasoning) reviewed b73d69b in the background and found nothing to report. Before the PR opened, three claude-opus-5-5 and claude-sonnet-5-5 reviewers and a sweep checked the diff; the stale scenario tests, docs that disagreed with the code, and two cleanups they found are fixed here.

🤖 Generated with Claude Code

Clearing a rating or date in Edit Metadata sent null, which the v2
metadata PATCH treated like an omitted field, so the old value came back
after a reload. Explicit null now clears the ten nullable members: the
four ratings, release, first and last air dates, air time, air timezone,
and season or episode air date. Clearing a rating also deletes the item's
stored score for that source, which title pages fall back to, and
clearing an episode air date recomputes the series air dates. Null on
other members and all of v1 keep treating null as omission.

Closes #2238

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-11T17:03:10.316391Z b73d69b PR opened
🔒 Security Review ✅ Completed 2026-10-11T17:04:23.367437Z b73d69b PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@silo-kody

silo-kody Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@coderabbitai

coderabbitai Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 944724f8-3a9c-4466-939d-b5488fbe407d



📥 Commits

Reviewing files that changed from the base of the PR and between cae87c8 and b73d69b.




📒 Files selected for processing (20)
  • contracts/api/v2/openapi.json
  • docs/admin-catalog-api.md
  • docs/architecture/discovery-row-ranking.md
  • docs/architecture/scenario-acceptance.md
  • docs/catalog-api.md
  • internal/api/handlers/admin.go
  • internal/api/handlers/admin_item_metadata_service.go
  • internal/apiv2/admin_catalog_item_metadata.go
  • internal/apiv2/admin_catalog_item_metadata_test.go
  • internal/catalog/episode_repo.go
  • internal/catalog/item_repo.go
  • internal/catalog/metadata_clear_db_test.go
  • internal/catalog/season_repo.go
  • internal/catalog/update.go
  • internal/scenariocatalog/executor/child_curation_test.go
  • internal/scenariocatalog/executor/item_curation_test.go
  • scripts/ci/db-contracts.txt
  • web/src/api/v2/schema.ts
  • web/src/components/EditMetadataDialog.test.tsx
  • web/src/components/EditMetadataDialog.tsx



Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.





📝 Walkthrough
📝 Walkthrough
📝 Walkthrough

Walkthrough

Explicit null values in v2 metadata updates now clear supported nullable fields. Clearing ratings also removes their source rows, and clearing an episode air date recomputes the series air date. The web editor, API descriptions, documentation, and tests reflect these semantics. The v1 path continues to treat null as omission.

Changes

Metadata clearing

Layer / File(s) Summary
Clearable metadata contract
internal/catalog/update.go
MetadataUpdate now identifies clearable columns, maps rating columns to source identifiers, and generates NULL assignments.
Catalog persistence
internal/catalog/item_repo.go, internal/catalog/season_repo.go, internal/catalog/episode_repo.go, internal/catalog/metadata_clear_db_test.go, scripts/ci/db-contracts.txt
Catalog updates apply supported clears. Item updates remove corresponding rating-source rows, and episode air-date clears trigger series air-date recomputation. Database tests cover item, season, and episode cases.
API null handling
internal/apiv2/admin_catalog_item_metadata.go, internal/apiv2/admin_catalog_item_metadata_test.go, internal/api/handlers/admin_item_metadata_service.go, internal/api/handlers/admin.go
The v2 API extracts explicit nulls for clearable fields from the raw request body and passes them to the catalog update. The v1 path passes no fields to clear.
Editor behavior and API contracts
web/src/components/EditMetadataDialog.tsx, web/src/components/EditMetadataDialog.test.tsx, web/src/api/v2/schema.ts, contracts/api/v2/openapi.json, docs/*, internal/scenariocatalog/executor/*
The editor submits null for a cleared timezone. Tests and API descriptions cover null-clearing behavior; documentation and scenario assertions describe which fields clear or remain unchanged.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant Editor as EditMetadataDialog
  participant API as v2 metadata API
  participant Service as UpdateCatalogItemMetadata
  participant Catalog as Catalog metadata repository
  participant DB as Database
  Editor->>API: Submit metadata fields, including explicit nulls
  API->>API: Extract clearable null fields from raw body
  API->>Service: Pass update request and cleared field names
  Service->>Catalog: Build MetadataUpdate with Clear fields
  Catalog->>DB: Set cleared columns to NULL
  Catalog->>DB: Delete source rows for cleared ratings
  Catalog->>DB: Recompute series air date when episode air date is cleared
Loading

Suggested reviewers: rhainland





Merge Risk: ⚪ Minimal · up to b73d6

No blocking issue is established for the metadata-clearing change; it is mergeable after normal checks.

Pre-merge checks | Passed 4 | Inconclusive 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage Inconclusive Docstring coverage is 44.44% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 13 files. (7 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check Passed Issue [#2238] requires the four rating fields cleared in the web Edit Metadata dialog to remain cleared after save and reload. The v2 handler detects explicit JSON null values. The catalog clear list …
Out of Scope Changes check Passed The changes remain connected to [#2238]. The date and time fields use the same null-versus-omission defect and the same metadata endpoint, so their added clear behavior is a related extension. Reposit…
Title check Passed The title clearly and concisely describes the main change: explicit null values now clear metadata ratings and dates.
Description check Passed The description directly explains the null-clearing behavior, implementation approach, affected fields, validation results, risks, and scope.

Full details: Docstring Coverage

Explanation

Docstring coverage is 44.44% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 13 files. (7 skipped: 6 unsupported, 1 too large.)


✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR




🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR





  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@silo-triage silo-triage Bot added api-v2 API v2 / Huma migration program (epic #135); long-running, stacked by phase bug Something isn't working go Pull requests that update go code javascript Pull requests that update javascript code priority: P2 Limited scope, workaround exists, or polish labels Oct 11, 2026
@Quick104
Quick104 merged commit 2365c5c into main Oct 11, 2026
20 checks passed
@Quick104
Quick104 deleted the fix/issue-2238 branch October 11, 2026 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api-v2 API v2 / Huma migration program (epic #135); long-running, stacked by phase bug Something isn't working go Pull requests that update go code javascript Pull requests that update javascript code priority: P2 Limited scope, workaround exists, or polish

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] Clearing a rating in Edit Metadata doesn't save; the old value comes back after refresh

1 participant