mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-02 05:12:11 +03:00
Clicking 'test' on a provider model (e.g. a ClinePass flash model) could freeze the entire dashboard. Root cause: POST /api/models/test returned an OBJECT in `error` on the Zod-validation and invalid-JSON paths (`validation.error.format()` / a details object). The client does `notify.error(data.error)`, and NotificationToast renders the message directly as a React child — an object throws React #31 ('Objects are not valid as a React child'), crashing the tree = frozen page instead of a toast. Fixed in three layers (defense in depth): 1. Server (root cause): /api/models/test now returns a STRING `error` on every path — flattens Zod issues to text, returns 'Invalid JSON body' for bad JSON. 2. Client: onTestModel funnels the response through extractApiErrorMessage() so any object-shaped error is coerced to a string before notify.error. 3. Toast: NotificationToast coerces title/message via toToastText() — a resilient catch-all so no future caller can freeze the page with a non-string. Tests (Rule #18, both node:test / blocking suite): - tests/unit/models-test-error-shape.test.ts — asserts STRING error on Zod-fail, missing-field, and invalid-JSON (fails on the pre-fix route: 3/3 red -> green). - tests/unit/notification-toast-coercion.test.ts — toToastText coercion matrix.