From 93463a94e39a37264ab3f4a8447fdce1b6c21935 Mon Sep 17 00:00:00 2001 From: Pavan-Microsoft Date: Thu, 23 Apr 2026 14:59:44 +0530 Subject: [PATCH 1/2] fix: add content-type check for non-JSON responses in HttpClient Co-authored-by: Copilot --- src/App/src/utils/httpClient.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/App/src/utils/httpClient.ts b/src/App/src/utils/httpClient.ts index 068146fc1..4ee850aa2 100644 --- a/src/App/src/utils/httpClient.ts +++ b/src/App/src/utils/httpClient.ts @@ -68,6 +68,10 @@ class HttpClient { if (!response.ok) { throw new Error(`${config.method || 'GET'} ${url} failed: ${response.statusText}`); } + const contentType = response.headers.get('content-type') || ''; + if (!contentType.toLowerCase().includes('application/json')) { + throw new Error(`${config.method || 'GET'} ${url} returned non-JSON response`); + } return response.json(); } } From 5756ebde9bb8c5f5037d05418dbf3fd7a2f39ece Mon Sep 17 00:00:00 2001 From: Pavan-Microsoft Date: Thu, 23 Apr 2026 15:31:09 +0530 Subject: [PATCH 2/2] fix: include content-type in error message for non-JSON responses in fetchExternal --- src/App/src/utils/httpClient.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/App/src/utils/httpClient.ts b/src/App/src/utils/httpClient.ts index 4ee850aa2..0acadaaaa 100644 --- a/src/App/src/utils/httpClient.ts +++ b/src/App/src/utils/httpClient.ts @@ -70,7 +70,7 @@ class HttpClient { } const contentType = response.headers.get('content-type') || ''; if (!contentType.toLowerCase().includes('application/json')) { - throw new Error(`${config.method || 'GET'} ${url} returned non-JSON response`); + throw new Error(`${config.method || 'GET'} ${url} returned non-JSON response (content-type: ${contentType || 'unknown'})`); } return response.json(); }