Merge pull request #3938 from koriyoshi2041/fix/replace-bare-except-handlers

fix: replace bare except handlers with specific exception types
This commit is contained in:
Mark Backman
2026-03-08 09:04:49 -04:00
committed by GitHub
7 changed files with 7 additions and 10 deletions

View File

@@ -70,7 +70,7 @@ class UrlToImageProcessor(FrameProcessor):
return data["artObject"]["webImage"]["url"]
if "artworks" in data and len(data["artworks"]):
return data["artworks"][0]["webImage"]["url"]
except:
except (json.JSONDecodeError, KeyError, TypeError):
pass
return None

View File

@@ -72,7 +72,7 @@ class UrlToImageProcessor(FrameProcessor):
return data["artObject"]["webImage"]["url"]
if "artworks" in data and len(data["artworks"]):
return data["artworks"][0]["webImage"]["url"]
except:
except (json.JSONDecodeError, KeyError, TypeError):
pass
async def run_image_process(self, image_url: str):

View File

@@ -209,7 +209,7 @@ class AWSBedrockLLMAdapter(BaseLLMAdapter[AWSBedrockLLMInvocationParams]):
tool_result_content = [{"json": content_json}]
else:
tool_result_content = [{"text": message["content"]}]
except:
except (json.JSONDecodeError, ValueError, AttributeError):
tool_result_content = [{"text": message["content"]}]
return {

View File

@@ -198,7 +198,7 @@ class TelnyxFrameSerializer(FrameSerializer):
f"Telnyx call {call_control_id} was already terminated"
)
return
except:
except Exception:
pass # Fall through to log the raw error
# Log other 422 errors

View File

@@ -212,7 +212,7 @@ class TwilioFrameSerializer(FrameSerializer):
if error_data.get("code") == 20404:
logger.debug(f"Twilio call {call_sid} was already terminated")
return
except:
except Exception:
pass # Fall through to log the raw error
# Log other 404 errors

View File

@@ -371,7 +371,7 @@ class AWSBedrockLLMContext(OpenAILLMContext):
tool_result_content = [{"json": content_json}]
else:
tool_result_content = [{"text": message["content"]}]
except:
except (json.JSONDecodeError, ValueError, AttributeError):
tool_result_content = [{"text": message["content"]}]
return {

View File

@@ -296,10 +296,7 @@ class MCPClient(BaseObject):
available_tools = await session.list_tools()
tool_schemas: List[FunctionSchema] = []
try:
logger.debug(f"Found {len(available_tools)} available tools")
except:
pass
logger.debug(f"Found {len(available_tools.tools)} available tools")
for tool in available_tools.tools:
tool_name = tool.name