feat(api): Implement EventManager error logging and add coverage (#29204)

- Ensure `EventManager._notify_layers` logs exceptions instead of silently swallowing them 
  so GraphEngine layer failures surface for debugging
- Introduce unit tests to assert the logger captures the runtime error when collecting events
- Enable the `S110` lint rule to catch `try-except-pass` patterns
- Add proper error logging for existing `try-except-pass` blocks.
This commit is contained in:
QuantumGhost
2025-12-08 09:40:40 +08:00
committed by GitHub
parent a25faa334a
commit 91667e3c1d
15 changed files with 103 additions and 33 deletions

View File

@@ -2,6 +2,7 @@
Unified event manager for collecting and emitting events.
"""
import logging
import threading
import time
from collections.abc import Generator
@@ -12,6 +13,8 @@ from core.workflow.graph_events import GraphEngineEvent
from ..layers.base import GraphEngineLayer
_logger = logging.getLogger(__name__)
@final
class ReadWriteLock:
@@ -180,5 +183,4 @@ class EventManager:
try:
layer.on_event(event)
except Exception:
# Silently ignore layer errors during collection
pass
_logger.exception("Error in layer on_event, layer_type=%s", type(layer))

View File

@@ -6,12 +6,15 @@ using the new Redis command channel, without requiring user permission checks.
Supports stop, pause, and resume operations.
"""
import logging
from typing import final
from core.workflow.graph_engine.command_channels.redis_channel import RedisChannel
from core.workflow.graph_engine.entities.commands import AbortCommand, GraphEngineCommand, PauseCommand
from extensions.ext_redis import redis_client
logger = logging.getLogger(__name__)
@final
class GraphEngineManager:
@@ -57,4 +60,4 @@ class GraphEngineManager:
except Exception:
# Silently fail if Redis is unavailable
# The legacy control mechanisms will still work
pass
logger.exception("Failed to send graph engine command %s for task %s", command.__class__.__name__, task_id)