Commit Graph
3 Commits
Author SHA1 Message Date
Jinjing e4eb1061fa Make project catalog normalizers handle null rows defensively
Instead of crashing when corrupt or null catalog rows are encountered,
the normalizers now gracefully repair them with default values. Refactored
helper functions for clarity and added type predicates to improve type
narrowing.
2026-08-27 10:50:03 -07:00
Jinjing 157d01c69e refactor(catalog): drop the as casts the normalizer introduced
A change whose thesis is "stop the declared types from lying" should not use
`as` to paper over types.

The four source casts all came from the row normalizers returning `readonly`
arrays into mutably-owned fields. Take and return mutable arrays instead, and
copy at the one caller that holds a readonly projection — where identity is
not load-bearing, unlike the persistence path, whose dirty check compares it.

Tests built deliberately malformed rows by casting a literal. Build a valid
row and `Reflect.set` the bad value onto it, which says outright that the
fixture violates its type; parse the non-array case from JSON, which is how
it actually arrives. Fixtures that were merely incomplete needed no cast at
all — `Repo` requires only the five fields they already had.

Also narrow normalizeLoadedProjectCatalog to the two fields it reads.
2026-08-27 09:16:54 -07:00
Jinjing 30e92d8dbe wip: normalize untrusted project catalog rows at load boundaries 2026-08-27 09:00:29 -07:00