Fix entry edit always failing with 'Input should be None'

Two bugs:

1. Python 3.12 name collision in schemas.py: `date: Optional[date] = None`
   caused get_type_hints() to resolve the `date` type annotation to NoneType
   (Optional[None]) because the field name shadowed the datetime.date import.
   All *Update schemas were rejecting any PUT with a valid date. Fixed by
   aliasing the import: `from datetime import date as Date`.

2. FastAPI validation errors return detail as a list of objects, not a string.
   Passing that list to new Error() produced "Error: [object Object]". Fixed
   in api.js to map the detail array to msg strings before throwing.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-22 20:37:15 -07:00
parent dcfc605579
commit d2afdc4ea3
2 changed files with 17 additions and 14 deletions

View File

@@ -13,7 +13,10 @@ const API = {
if (!res.ok) {
const err = await res.json().catch(() => ({ detail: res.statusText }));
throw new Error(err.detail || `Request failed (${res.status})`);
const detail = Array.isArray(err.detail)
? err.detail.map(e => e.msg).join(', ')
: err.detail;
throw new Error(detail || `Request failed (${res.status})`);
}
if (res.status === 204) return null; // DELETE returns No Content
return res.json();