fix(plex): stop /facets 500 on a metadata-poor library

A mirrored Shows library whose items have no genres stored `genres` as JSON
`null` — SQLAlchemy's JSONB persists a Python None as a JSON scalar, not SQL
NULL. /facets unnested it with jsonb_array_elements_text(), which raises
"cannot extract elements from a scalar", so a single bare library 500'd the
whole Plex module on open (the grid loads, the filter sidebar's facets call dies).

- Guard the /facets genre unnest with jsonb_typeof(genres)='array', mirroring
  the guard people.py already applies to the same columns.
- Persist the JSONB tag columns (genres/directors/cast_names/collection_keys on
  plex_items and plex_shows) with none_as_null=True, so an empty list round-trips
  as SQL NULL and self-heals on the next sync — closing the trap for any future
  unnest.

Verified against the real prod row (DumaTV show, genres = JSON null): the
unguarded query errors, the guarded one returns cleanly.
This commit is contained in:
2026-07-25 18:22:07 +02:00
parent 08049d2aa5
commit 58f836bcd8
4 changed files with 26 additions and 10 deletions
+8
View File
@@ -14,6 +14,14 @@ export interface ReleaseEntry {
}
export const RELEASE_NOTES: ReleaseEntry[] = [
{
version: "0.53.1",
date: "2026-07-25",
summary: "The Plex page no longer errors when a mirrored library has items without genres.",
fixes: [
"Opening the Plex module could fail with a server error when a mirrored library contained items with no genre metadata (for example a freshly added, sparsely-tagged library). The filter sidebar now handles genre-less items correctly, so the page loads normally.",
],
},
{
version: "0.53.0",
date: "2026-07-23",