From 92c86cab80c93943414f8d8c576df4138f716b08 Mon Sep 17 00:00:00 2001 From: chihlasm Date: Wed, 11 Mar 2026 23:56:45 -0400 Subject: [PATCH] fix: handle object-shaped validation errors in KB commit error toast The commit endpoint returns {message, validation_errors} when validation fails, but the error handler was passing the whole object to toast.error(), crashing React with "Objects are not valid as a React child". Co-Authored-By: Claude Opus 4.6 --- frontend/src/pages/KBAcceleratorPage.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/frontend/src/pages/KBAcceleratorPage.tsx b/frontend/src/pages/KBAcceleratorPage.tsx index 63d58c3c..b66aa3e4 100644 --- a/frontend/src/pages/KBAcceleratorPage.tsx +++ b/frontend/src/pages/KBAcceleratorPage.tsx @@ -140,8 +140,14 @@ export default function KBAcceleratorPage() { // Refresh quota kbAcceleratorApi.getQuota().then(setQuota).catch(() => {}) } catch (err: unknown) { - const message = (err as { response?: { data?: { detail?: string } } })?.response?.data?.detail ?? 'Commit failed' - toast.error(message) + const detail = (err as { response?: { data?: { detail?: string | { message?: string; validation_errors?: string[] } } } })?.response?.data?.detail + if (typeof detail === 'object' && detail !== null) { + const msg = detail.message || 'Commit failed' + const errors = detail.validation_errors + toast.error(errors?.length ? `${msg}\n${errors.join('\n')}` : msg) + } else { + toast.error(typeof detail === 'string' ? detail : 'Commit failed') + } } finally { setLoading(false) }