fix: replace silent exception swallowing with proper logging

This commit is contained in:
2025-11-18 19:22:02 +05:30
parent cbcb2d41ab
commit 1d9765fd38
4 changed files with 24 additions and 14 deletions
+1 -2
View File
@@ -210,8 +210,7 @@ class Node: # pylint: disable=too-many-instance-attributes
try:
agent_response = await agent.process_message(agent_input, context)
except Exception as e: # pylint: disable=broad-exception-caught
# Catch all agent exceptions to prevent node failure
self.logger.error("Agent %s execution failed: %s", agent.name, e)
self.logger.error("Agent %s execution failed: %s", agent.name, e, exc_info=True)
agent_response = f"Error processing message: {str(e)}"
# Return state updates
+4 -3
View File
@@ -249,8 +249,8 @@ class BaseTemplate(ABC):
# Replace single quotes with double quotes for JSON parsing
json_str = rendered.replace("'", '"')
return json.loads(json_str)
except Exception: # pylint: disable=broad-exception-caught
pass
except (json.JSONDecodeError, ValueError) as e:
logger.debug("Failed to parse as JSON: %s", e)
try:
# Try to parse as number
@@ -284,7 +284,8 @@ class BaseTemplate(ABC):
try:
return yaml.safe_load(rendered)
except Exception: # pylint: disable=broad-exception-caught
except yaml.YAMLError as e:
logger.warning("Failed to parse YAML in conditional: %s", e)
return rendered
# Condition was false, exclude this section
return None
@@ -91,9 +91,13 @@ class GraphTemplate(BaseTemplate):
agent_ref,
node_name,
)
except Exception: # pylint: disable=broad-exception-caught
# Not a local reference, probably a global agent name
pass
except Exception as e: # pylint: disable=broad-exception-caught
logger.debug(
"Could not resolve agent reference '%s' in node '%s': %s",
agent_ref,
node_name,
e
)
processed_nodes[node_name] = node_config
+12 -6
View File
@@ -105,9 +105,12 @@ class StreamTemplate(BaseTemplate):
logger.debug(
"Resolved agent reference '%s' in stream operator", agent_ref
)
except Exception: # pylint: disable=broad-exception-caught
# Not a local reference, probably a global agent name
pass
except Exception as e: # pylint: disable=broad-exception-caught
logger.debug(
"Could not resolve agent reference '%s' in stream operator: %s",
agent_ref,
e
)
# Handle graph references in graph_execute operators
if op_type == "graph_execute" and "graph" in op_params:
@@ -127,9 +130,12 @@ class StreamTemplate(BaseTemplate):
logger.debug(
"Resolved graph reference '%s' in stream operator", graph_ref
)
except Exception: # pylint: disable=broad-exception-caught
# Not a local reference, probably a global graph name
pass
except Exception as e: # pylint: disable=broad-exception-caught
logger.debug(
"Could not resolve graph reference '%s' in stream operator: %s",
graph_ref,
e
)
processed_operators.append(operator)