fix(admin): serialize unset config fields using their defaults - #3
fix(admin): serialize unset config fields using their defaults#3jmagar wants to merge 3 commits into
Conversation
- serializeConfig now falls back to a field's default (0/false/"" as type-appropriate last resorts) instead of emitting null for unset number/boolean/text values - surface the real error message when admin setup fails instead of a generic "Try again." - add test covering effective-default serialization - rebuild bundled frontend assets
Consolidated fixes from review agents on serializeConfig: - number/boolean/enable/text fields with no value and no default are now omitted from the serialized payload instead of coercing to 0/false/"". The Go ApplyPatch handler (server/common/config.go:325) already skips absent keys and preserves existing/dynamic defaults, so silently pinning e.g. force_ssl=false on save was a real regression risk. The recursive object walk explicitly drops undefined leaves so omission is unambiguous. - guard the remaining unguarded `(error as Error).message` casts in admin.tsx (session, setup, save) with the `instanceof Error` idiom already used elsewhere, with sensible fallback copy. - extend admin.test.ts with cases for value/default omission, falsy-but-set booleans, zero-but-set numbers, and enable defaults. - add component-level tests in admin-screen.test.tsx covering the setup error path for both Error and non-Error rejections. Rebuilt and staged public/ via `make frontend-stage` so the embedded assets match the new admin.tsx bundle.
Two renamed chunk files were left out of the previous commit's explicit path list; complete the frontend-stage output.
|
Applied fixes from the three converging review passes (commits Critical semantics fix — Error message guards — replaced the remaining unguarded Test coverage — extended All touched tests pass (14/14), plus Also rebuilt and staged |
serializeConfignow falls back to a field'sdefault(with type-appropriate last resorts:0/false/"") instead of emittingnullfor unset number/boolean/text valuespublic/)