Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugins/communication_protocols/http/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "utcp-http"
version = "1.0.2"
version = "1.0.3"
authors = [
{ name = "UTCP Contributors" },
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,11 @@ async def call_tool(self, caller, tool_name: str, tool_args: Dict[str, Any], too

content_type = response.headers.get('Content-Type', '').lower()
if 'application/json' in content_type:
return await response.json()
try:
return await response.json()
except Exception:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overly broad exception handler hides unexpected errors; catch specific JSON parsing/decode exceptions instead for safer error handling.

Prompt for AI agents
Address the following comment on plugins/communication_protocols/http/src/utcp_http/http_communication_protocol.py at line 318:

<comment>Overly broad exception handler hides unexpected errors; catch specific JSON parsing/decode exceptions instead for safer error handling.</comment>

<file context>
@@ -313,7 +313,11 @@ async def call_tool(self, caller, tool_name: str, tool_args: Dict[str, Any], too
-                        return await response.json()
+                        try:
+                            return await response.json()
+                        except Exception:
+                            logger.error(f&quot;Error parsing JSON response from tool &#39;{tool_name}&#39; on call template &#39;{tool_call_template.name}&#39;, even though Content-Type was application/json&quot;)
+                            return await response.text()
</file context>
Suggested change
except Exception:
except (json.JSONDecodeError, UnicodeDecodeError):

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")
return await response.text()
return await response.text()

except aiohttp.ClientResponseError as e:
Expand Down
Loading