From ec060c9dbffed9a1bc62580e39df161005d85b0d Mon Sep 17 00:00:00 2001 From: Devanshu Rajesh Chicholikar Date: Mon, 12 Jan 2026 17:08:43 -0500 Subject: [PATCH] fix: validate response before using repo_id (#207) - check response.ok before parsing json - validate repo_id exists before triggering index - prevents undefined repo_id in API calls --- frontend/src/components/dashboard/DashboardHome.tsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/frontend/src/components/dashboard/DashboardHome.tsx b/frontend/src/components/dashboard/DashboardHome.tsx index feeb9c8..e2d5115 100644 --- a/frontend/src/components/dashboard/DashboardHome.tsx +++ b/frontend/src/components/dashboard/DashboardHome.tsx @@ -57,7 +57,15 @@ export function DashboardHome() { }, body: JSON.stringify({ name, git_url: gitUrl, branch }) }) + + if (!response.ok) { + const err = await response.json().catch(() => ({})) + throw new Error(err.detail || 'Failed to add repository') + } + const data = await response.json() + if (!data.repo_id) throw new Error('Missing repo_id in response') + await fetch(`${API_URL}/repos/${data.repo_id}/index`, { method: 'POST', headers: { 'Authorization': `Bearer ${session?.access_token}` }