Skip to content

Commit 86ef9c9

Browse files
authored
Merge pull request #208 from DevanshuNEU/fix/207-undefined-repo-id
fix: validate response before using repo_id (#207)
2 parents 0298ea4 + ec060c9 commit 86ef9c9

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

frontend/src/components/dashboard/DashboardHome.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,15 @@ export function DashboardHome() {
5757
},
5858
body: JSON.stringify({ name, git_url: gitUrl, branch })
5959
})
60+
61+
if (!response.ok) {
62+
const err = await response.json().catch(() => ({}))
63+
throw new Error(err.detail || 'Failed to add repository')
64+
}
65+
6066
const data = await response.json()
67+
if (!data.repo_id) throw new Error('Missing repo_id in response')
68+
6169
await fetch(`${API_URL}/repos/${data.repo_id}/index`, {
6270
method: 'POST',
6371
headers: { 'Authorization': `Bearer ${session?.access_token}` }

0 commit comments

Comments
 (0)