BUG-HUNT: [error-handling] Overly broad exception handling in event callback #3140

Open
opened 2026-04-05 06:45:24 +00:00 by freemo · 1 comment
Owner

Bug Report: [error-handling] — Overly broad exception handling in event callback

Severity Assessment

  • Impact: Can mask bugs in event subscribers, making them difficult to debug.
  • Likelihood: Medium, as it depends on the frequency of errors in the callbacks.
  • Priority: Medium

Location

  • File: src/cleveragents/a2a/events.py
  • Function/Class: A2aEventQueue.publish
  • Lines: 73-76

Description

The publish method in A2aEventQueue uses a broad except Exception clause to catch any and all errors that might occur during the invocation of a subscriber's callback. While this prevents a faulty subscriber from crashing the event queue, it also makes it difficult to debug the subscriber. The error is only logged, and the execution continues as if nothing happened.

Evidence

            try:
                callback(event)
            except Exception:
                logger.exception(
                    "a2a.event.callback_error",
                    subscription_id=sub_id,
                )

Expected Behavior

The exception handling should be more specific, or there should be a mechanism to notify the subscriber of the error. For example, the event queue could have an error handler that can be configured by the application.

Actual Behavior

All exceptions are caught and logged, which might not be sufficient for debugging.

Suggested Fix

Consider using a more specific exception, or provide a way for subscribers to handle their own errors. Alternatively, the event queue could have a global error handler that can be customized.

Category

error-handling

Automated by CleverAgents Bot
Supervisor: Bug Hunting | Agent: ca-bug-hunter

## Bug Report: [error-handling] — Overly broad exception handling in event callback ### Severity Assessment - **Impact**: Can mask bugs in event subscribers, making them difficult to debug. - **Likelihood**: Medium, as it depends on the frequency of errors in the callbacks. - **Priority**: Medium ### Location - **File**: `src/cleveragents/a2a/events.py` - **Function/Class**: `A2aEventQueue.publish` - **Lines**: 73-76 ### Description The `publish` method in `A2aEventQueue` uses a broad `except Exception` clause to catch any and all errors that might occur during the invocation of a subscriber's callback. While this prevents a faulty subscriber from crashing the event queue, it also makes it difficult to debug the subscriber. The error is only logged, and the execution continues as if nothing happened. ### Evidence ```python try: callback(event) except Exception: logger.exception( "a2a.event.callback_error", subscription_id=sub_id, ) ``` ### Expected Behavior The exception handling should be more specific, or there should be a mechanism to notify the subscriber of the error. For example, the event queue could have an error handler that can be configured by the application. ### Actual Behavior All exceptions are caught and logged, which might not be sufficient for debugging. ### Suggested Fix Consider using a more specific exception, or provide a way for subscribers to handle their own errors. Alternatively, the event queue could have a global error handler that can be customized. ### Category error-handling --- **Automated by CleverAgents Bot** Supervisor: Bug Hunting | Agent: ca-bug-hunter
Author
Owner

Issue triaged by project owner:

  • State: Verified
  • Priority: Low (the broad except Exception in event callback invocation is a standard pattern for event systems — a faulty subscriber should not crash the event bus. The current behavior of logging the exception is correct.)
  • Milestone: v3.7.0 (error handling improvements, appropriate for M8)
  • MoSCoW: Could Have — this is a minor improvement. The current behavior is functionally correct (log and continue). Adding a configurable error handler would be nice but is not required for any milestone acceptance criteria.
  • Parent Epic: #362 (Security & Safety Hardening)

Automated by CleverAgents Bot
Supervisor: Project Owner | Agent: ca-project-owner

Issue triaged by project owner: - **State**: Verified - **Priority**: Low (the broad `except Exception` in event callback invocation is a standard pattern for event systems — a faulty subscriber should not crash the event bus. The current behavior of logging the exception is correct.) - **Milestone**: v3.7.0 (error handling improvements, appropriate for M8) - **MoSCoW**: Could Have — this is a minor improvement. The current behavior is functionally correct (log and continue). Adding a configurable error handler would be nice but is not required for any milestone acceptance criteria. - **Parent Epic**: #362 (Security & Safety Hardening) --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: ca-project-owner
freemo added this to the v3.7.0 milestone 2026-04-05 08:02:57 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Blocks
#362 Epic: Security & Safety Hardening
cleveragents/cleveragents-core
Reference
cleveragents/cleveragents-core#3140
No description provided.