Harden channel graphicsElementIds: validate unknown ids (422 not 500) + builtIn discriminator (#74 follow-up) #567

Closed
opened 2026-07-22 22:10:05 +02:00 by timothy · 1 comment
Owner

Follow-ups from the #74 (On Now/Next overlay) whole-branch review. Both are Minor, data-safe, and not reachable from the SPA (which only ever sends the real built-in id), so they were deferred out of #74.

1. Unknown graphicsElementIds returns 500 instead of 422

UpdateChannelHandler.Validate checks name/number/EPG/logo/group but never validates the incoming graphics-element ids. The reconcile blindly Adds a ChannelGraphicsElement for any id, so a PUT /api/v1/channels/{id} with a non-existent id hits the FK_ChannelGraphicsElement_GraphicsElement_GraphicsElementId constraint → DbUpdateException → unhandled 500. Data-safe (the transaction rolls back), but it should return 422 for parity with every other field on this full-replace DTO — cf. api.scheduling-hardening (prevent write-path 500s). Add a validator that rejects ids not present in GraphicsElements.

2. builtIn discriminator is filename-only, case-sensitive, folder-agnostic

GetAllGraphicsElementsForApiHandler and GraphicsElementSeeder key builtIn off Path.GetFileName(e.Path) == GraphicsElementDefaults.OnNowNextFileName. A user element named exactly on-now-next.yml in any graphics folder would also report builtIn:true, and the SPA findBuiltInOnNowNext .find()s the first match. Contrived/self-inflicted, but consider hardening (e.g. match the full seeded relative path, or a dedicated discriminator).

Source: #74 whole-branch adversarial review (2026-07-22).

Follow-ups from the #74 (On Now/Next overlay) whole-branch review. Both are Minor, data-safe, and not reachable from the SPA (which only ever sends the real built-in id), so they were deferred out of #74. ## 1. Unknown `graphicsElementIds` returns 500 instead of 422 `UpdateChannelHandler.Validate` checks name/number/EPG/logo/group but never validates the incoming graphics-element ids. The reconcile blindly `Add`s a `ChannelGraphicsElement` for any id, so a `PUT /api/v1/channels/{id}` with a non-existent id hits the `FK_ChannelGraphicsElement_GraphicsElement_GraphicsElementId` constraint → `DbUpdateException` → unhandled **500**. Data-safe (the transaction rolls back), but it should return **422** for parity with every other field on this full-replace DTO — cf. `api.scheduling-hardening` (prevent write-path 500s). Add a validator that rejects ids not present in `GraphicsElements`. ## 2. `builtIn` discriminator is filename-only, case-sensitive, folder-agnostic `GetAllGraphicsElementsForApiHandler` and `GraphicsElementSeeder` key `builtIn` off `Path.GetFileName(e.Path) == GraphicsElementDefaults.OnNowNextFileName`. A user element named exactly `on-now-next.yml` in any graphics folder would also report `builtIn:true`, and the SPA `findBuiltInOnNowNext` `.find()`s the first match. Contrived/self-inflicted, but consider hardening (e.g. match the full seeded relative path, or a dedicated discriminator). Source: #74 whole-branch adversarial review (2026-07-22).
Author
Owner

Duplicate of #568 (accidental double-file — the first create request errored on the follow-up label call but the issue was created). Tracking in #568.

Duplicate of #568 (accidental double-file — the first create request errored on the follow-up label call but the issue was created). Tracking in #568.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: timothy/ersatztv#567