From 6c8fc0ff6dc10c9fac2f5b84bfef275d39db700d Mon Sep 17 00:00:00 2001 From: Ishaan Jaffer Date: Fri, 17 Apr 2026 17:50:46 -0700 Subject: [PATCH] [Skills UI] fix non-JSON error handling in testGitHubSkillConnection and createSkillFromGitHub --- .../src/components/networking.tsx | 42 +++++++++++++------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/ui/litellm-dashboard/src/components/networking.tsx b/ui/litellm-dashboard/src/components/networking.tsx index 5baa888cfbb..3f626282659 100644 --- a/ui/litellm-dashboard/src/components/networking.tsx +++ b/ui/litellm-dashboard/src/components/networking.tsx @@ -10014,15 +10014,24 @@ export const testGitHubSkillConnection = async ( pat: string, ): Promise<{ status: string; message?: string }> => { const base = proxyBaseUrl ?? ""; - const response = await fetch(`${base}/v1/skills/test-github-connection`, { - method: "POST", - headers: { - [globalLitellmHeaderName]: `Bearer ${accessToken}`, - "Content-Type": "application/json", - }, - body: JSON.stringify({ repo_url: repoUrl, github_pat: pat }), - }); - return response.json(); + try { + const response = await fetch(`${base}/v1/skills/test-github-connection`, { + method: "POST", + headers: { + [globalLitellmHeaderName]: `Bearer ${accessToken}`, + "Content-Type": "application/json", + }, + body: JSON.stringify({ repo_url: repoUrl, github_pat: pat }), + }); + const text = await response.text(); + try { + return JSON.parse(text); + } catch { + return { status: "error", message: text || `HTTP ${response.status}` }; + } + } catch (e: any) { + return { status: "error", message: e?.message ?? "Network error" }; + } }; export const createSkillFromGitHub = async ( @@ -10045,9 +10054,18 @@ export const createSkillFromGitHub = async ( display_title: displayTitle || undefined, }), }); + const text = await response.text(); if (!response.ok) { - const err = await response.text(); - throw new Error(err); + let message = text; + try { + const parsed = JSON.parse(text); + message = parsed?.detail ?? parsed?.message ?? text; + } catch { /* use raw text */ } + throw new Error(message || `HTTP ${response.status}`); + } + try { + return JSON.parse(text); + } catch { + throw new Error(`Unexpected response: ${text}`); } - return response.json(); };