From 66670bc9fb0a8d5e9b2398ca21ae63c1e79da4a1 Mon Sep 17 00:00:00 2001 From: Ajax Davis Date: Thu, 15 Jan 2026 00:01:05 +1000 Subject: [PATCH] fix: add error handling for collection env vars save --- .../app/dashboard/collections/[id]/page.tsx | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/apps/web/src/app/dashboard/collections/[id]/page.tsx b/apps/web/src/app/dashboard/collections/[id]/page.tsx index 8eeb86e..f4abfc7 100644 --- a/apps/web/src/app/dashboard/collections/[id]/page.tsx +++ b/apps/web/src/app/dashboard/collections/[id]/page.tsx @@ -624,14 +624,24 @@ export default function CollectionDetailPage(): React.ReactElement {
{ + onChange={async (newEnvVars) => { setEnvVars(newEnvVars); - // Auto-save env vars - fetch(`/api/collections/${collectionId}`, { - method: 'PATCH', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ envVars: newEnvVars }), - }); + // Auto-save env vars with error handling + try { + const response = await fetch(`/api/collections/${collectionId}`, { + method: 'PATCH', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ envVars: newEnvVars }), + }); + const result = await response.json(); + if (!result.success) { + console.error('Failed to save env vars:', result.error); + alert(`Failed to save environment variables: ${result.error || 'Unknown error'}`); + } + } catch (err) { + console.error('Failed to save env vars:', err); + alert('Failed to save environment variables. Please try again.'); + } }} title="Environment Variables" description="These variables are passed to tools at runtime. Use them to store API keys and configuration."