Repository navigation
Conversation
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Validate metadata dates internal/apiv2/admin_catalog_item_metadata.go, internal/apiv2/admin_catalog_item_metadata_test.go, docs/admin-catalog-api.md |
The update handler validates non-null date values as YYYY-MM-DD dates with a year of at least 1. Invalid values produce field-specific validation errors and prevent the service call. Tests cover invalid dates, a valid leap day, and clearing a date with null. The API documentation describes the validation and frozen v1 behavior. |
Priority:
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix · Severity of issue fixed: Medium
Possibly related issues
- Silo-Server/silo-server#2277: The reported malformed and empty date inputs returning 500 are addressed by validation that returns 422 before the metadata service runs. The request to reject null for other members is not covered.
Possibly related PRs
- Silo-Server/silo-server#2254: The validation gate runs before the metadata service call, where this PR publishes catalog-change events.
Suggested reviewers: quick104
Merge Risk: 
Minimal · up to 60dee
-
The documented v2 date-validation behavior is implemented and covered across the handler and transport tests, with no actionable merge-blocking risk identified.
Security architecture risk: 
Minimal · up to 60dee
-
The change rejects malformed dates before any metadata write while preserving existing permissions, valid updates, and explicit date clears. No material security risk was found introduced or worsened by this change.
Retained concerns
No architecture-level concerns identified.Security review details
-
Security Blast Radius
- inferred — The changed behavior is confined to date inputs on the existing authorized catalog metadata PATCH operation. It narrows values reaching item, season, and episode persistence without adding caller authority, another service destination, or a new persistence owner.
Trust Boundaries and Controls
- observed — The route retains its metadata-curation permission gate. Production controls authenticate the caller, check enabled identity and permission, resolve target libraries, and enforce applicable library scope before dispatching to the handler. Date validation does not bypass those controls.
Resilience and Maintainability Implications
- observed — Malformed requests now terminate before mutation, including when other valid edits accompany an invalid date. Accepted updates retain existing transactional containment: media-item writes group dependent work in a transaction, and episode writes commit derived series dates with the episode change. No new mutable state or cleanup obligation is added by validation.
-
Pre-merge checks: 
5
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment @coderabbitai help to get the list of available commands.
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 API excerpts show the new
Include Suggested fix: No diff. 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:
|
PATCH /api/v2/admin/items/{id}/metadata passed date members to the
repositories as text. An empty or malformed release_date or air_date
failed the write in PostgreSQL and the request answered 500
internal_error; the same value in first_air_date or last_air_date (text
columns) was stored as given.
The handler now checks the four date members before calling the
service: a value must be a YYYY-MM-DD calendar date, and anything else
is 422 validation_failed at body.<member>, with every bad member named
and nothing written. Null still clears these dates. Frozen v1 is
unchanged.
Refusing null on members that can't be cleared, the other half of the
issue, narrows the v2 request schema and is left for a separate change.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…date test CONTRIBUTING's "Decide what to test" counts several bad inputs that reach the same error path as one case. One request now sends a bad value for each of the four date members, including year 0 (which time.Parse accepts and PostgreSQL rejects), and checks that every member is named and nothing reaches the service; a second checks that a real date passes and null still clears. Co-Authored-By: Claude Opus 5.5 <[email protected]>
f9c41c1 to
60dee0d
Compare
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:
|
Quick104
left a comment
There was a problem hiding this comment.
Reviewed 60dee0d562e2ae4b748c26afbd2ae1dcc85b833f. No actionable findings.
The focused metadata transport and date-validation tests pass. The new malformed-date test fails against the merge base with HTTP 200 instead of 422. The validation runs before persistence and preserves null clearing and frozen v1 behavior.
Validation tasks: none. No passed-case impact was found in the live validation issue records. Direct board enumeration was unavailable because the review credential lacks read:project; this was not an exhaustive board check.
Reviewed with Codex (gpt-6.1-sol), using independent xhigh review and verification passes.
Requested by Tobechukwu Njoku
Problem
Related issue: #2277
Validation tasks: none
PATCH /api/v2/admin/items/{id}/metadatapasses its date members to the database as text. An empty or malformedrelease_date, or a season or episodeair_date, makes PostgreSQL reject the write, and the request answers500 internal_error. The same value infirst_air_dateorlast_air_date, which are text columns, is stored as given:"2024-13-01"is saved and comes back on the item. With this change the handler refuses any of the four that isn't aYYYY-MM-DDdate with422 validation_failednaming the member.This is the first half of #2277. The second half, refusing
nullon members that can't be cleared, is not in this PR (see Approach), so the issue stays open.Approach
The v2 handler checks
release_date,first_air_date,last_air_dateandair_datebefore it calls the metadata service. A value must parse as aYYYY-MM-DDcalendar date with a year of 1 or later (PostgreSQL'sdatehas no year 0). Anything else, including the empty string, is422 validation_failedwith aninvaliderror atbody.<member>for each bad member, and nothing is written.nullstill clears these dates and omission still leaves them alone. The request schema is unchanged;docs/admin-catalog-api.mdstates the rule. The check sits in the v2 handler, so frozen v1 behaves as before.Refusing
nullon members that can't be cleared (title,year,genres, and so on) means droppingnullablefrom those members ofAdminItemMetadataUpdate. That narrows the v2 request schema, whichmake verify-apiv2-contracttreats as breaking, so it needs a maintainer's breaking-change approval before anyone builds it. Until thennullon those members still returns 200 and changes nothing.Validation
release_dateor season or episodeair_datereturns 500, and a malformedfirst_air_dateorlast_air_datereturns 200 and is stored. On this branch each of them returns 422 at the member, and valid dates andnullstill return 200.2024-02-30,0000-01-01, an RFC 3339 timestamp) and gets oneinvaliderror per member, with nothing reaching the service; a second checks that a real date passes andnullstill clears. Without the check it fails with 200.go build ./...,gofmt,go vet ./...andmake lint-changedare clean.make test-gopasses apart from three tests that fail the same way on main 9e81ab0 in this environment (twojellycompatPlaybackInfo tests andTestProvider_DirectoryListingFollowsChangesinmetadata/nfo).internal/apiv2and oneapi/handlerstiming test failed under machine load in the parallel run and pass when run on their own.Evidence
PATCH /api/v2/admin/items/{id}/metadataon a local server and database, with the same items and requests in the order shown: before on main 9e81ab0, after on this branch at 6ad3711. "Stored as" is the column value read back from PostgreSQL.Movie (
release_date,first_air_date), before:After:
Series (
last_air_date), season and episode (air_date), before:After:
Risks
A v2 client that sent
""or another non-date string infirst_air_dateorlast_air_dateused to get 200 with the string stored; it now gets 422. The API contract already says date-only values areYYYY-MM-DD, and the web metadata dialog sends either aYYYY-MM-DDdate from a date input ornull, so it is not affected. No schema, fixture or v1 change.Checklist
AI Disclosure
Note
Reject malformed YYYY-MM-DD dates in apiv2 item metadata edits
Adds
rejectMalformedMetadataDatesvalidation before the metadata service call in the admin item metadata update handler. Non-null date members (release,first-air,last-air,air) must parse as valid YYYY-MM-DD calendar dates with year >= 1; failures return a 422 validation error per member and no write occurs. Null dates are still skipped and cleared. Tests cover empty, impossible, year-0, and timestamp-formatted values in admin_catalog_item_metadata_test.go; docs updated in admin-catalog-api.md.Macroscope summarized 60dee0d.