Skip to content

Commit a188304

Browse files
committed
Fix response json parsing when content type is wrong
1 parent e1b1fd9 commit a188304

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

plugins/communication_protocols/http/src/utcp_http/http_communication_protocol.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,11 @@ async def call_tool(self, caller, tool_name: str, tool_args: Dict[str, Any], too
313313

314314
content_type = response.headers.get('Content-Type', '').lower()
315315
if 'application/json' in content_type:
316-
return await response.json()
316+
try:
317+
return await response.json()
318+
except Exception:
319+
logger.error(f"Error parsing JSON response from tool '{tool_name}' on call template '{tool_call_template.name}', even though Content-Type was application/json")
320+
return await response.text()
317321
return await response.text()
318322

319323
except aiohttp.ClientResponseError as e:

0 commit comments

Comments
 (0)