Files
ersatztv/docs/decisions/records/api
TimothyandClaude Opus 5 4466ea894c fix(880): an absent recurrence array means unrestricted, an explicit [] is rejected
The three recurrence arrays on the two playout write paths are consumed
CONJUNCTIVELY by AlternateScheduleSelector.GetScheduleForDate -- a miss on any
one `continue`s -- so the empty set is the maximally RESTRICTIVE value, not a
neutral one. `?? []` on an omitted array therefore read as "default to no
filter" and meant "default to matching nothing": the API returned HTTP 200 and
stored an alternate-schedule or template item that could never apply on any
date, with nothing logged. The read side had already been decided the other way
in #823 (a NULL column reads as the All*() sets), so the two halves of "this
field is absent" pointed in opposite directions -- residual (3) of
media.nullable-primitive-collection-mutation.

Absent and explicitly-empty are two different requests and get two answers:

- ABSENT (missing, or an explicit `null` -- Newtonsoft maps both to null and
  they are indistinguishable) normalizes to AlternateScheduleSelector.All*(),
  the SAME symbols the selector's null guard and both Mapper.ProjectToViewModel
  overloads already substitute. Requires List<T>? on the request records, hence
  the per-file `#nullable enable` the sibling request records already use.
- EXPLICIT [] is rejected with a 422 naming the consequence, per
  api.ffmpeg-profile-numeric-bounds -- not rewritten into the permissive value,
  which would re-collapse the distinction in the other direction and make "no
  days" inexpressible.

Checked before committing to the normalization, because it is a write-path
semantics change: the SPA's generated type is `null | Array<T>` (nullable, not
optional) and PlayoutScheduleEditors.tsx always sends the key, and
ErsatzTV.Mcp/ToolCatalog.cs explicitly defers these replace-list writes. So no
existing client takes the absent path -- the trap was reachable only by a direct
API client omitting a field.

Rejection is uniform across items, including the highest-Index catch-all whose
recurrence the handler discards. Exempting it would restate "which item is the
catch-all" in the controller, a second copy of a rule that lives in the handler
(api.put-replace-index-order); ValidateDateRanges already makes exactly this
choice for the date fields it equally discards.

Prod was measured before choosing to reject rather than grandfather an existing
empty row: ProgramScheduleAlternate and PlayoutTemplate both hold ZERO rows
(jazz /config/ersatztv.sqlite3, 2026-08-30), so no stored [] can be bricked and
the ffmpeg-profile compare-against-stored exemption was not needed.

Both halves mutation-proved by execution, separately, against the real
predecessor clause: reverting the `?? All*()` normalization alone reddens
exactly the 3 normalization tests; removing the two ValidateRecurrenceSets call
sites alone reddens exactly the 6 rejection cases. Disjoint sets, so the guards
are not masking each other.

OpenAPI and the generated SPA client are byte-identical before and after -- a
non-nullable-annotated List<T> was already emitted as nullable -- so the
contract shape did not move, only the behaviour behind it.

fixes #880

Decisions-Edit: yes
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019zUmJZHhVP7kXg5DV237TW
2026-08-30 10:25:45 +02:00
..