BUG-HUNT: [error-handling] Broad exception in A2aEventQueue.publish #5897

Open
opened 2026-04-09 11:36:20 +00:00 by HAL9000 · 0 comments
Owner

Bug Report: [error-handling] — Broad exception in A2aEventQueue.publish

Severity Assessment

  • Impact: May catch system-level exceptions that should not be caught, potentially hiding critical errors.
  • Likelihood: High, as it catches any exception.
  • Priority: Low

Location

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

Description

The except Exception: in A2aEventQueue.publish is too broad. It catches any exception, including system-level exceptions like SystemExit and KeyboardInterrupt, which might not be desirable. While this might be acceptable for a callback system to prevent one failing callback from stopping the entire event propagation, it's better to catch more specific exceptions.

Evidence

        for sub_id, callback in self._subscriptions.items():
            try:
                callback(event)
            except Exception:
                logger.exception(
                    "a2a.event.callback_error",
                    subscription_id=sub_id,
                )

Expected Behavior

The code should catch more specific exceptions, such as RuntimeError or a custom callback execution error, to avoid swallowing critical system-level exceptions.

Actual Behavior

The code catches any exception, which could hide bugs or prevent the application from shutting down gracefully.

Suggested Fix

Replace except Exception: with a more specific exception type, or a tuple of specific exception types, that are expected to be raised by the callbacks.

Category

error-handling

TDD Note

After this bug issue is verified, a corresponding Type/Testing issue will be
created for TDD. The test will use tags: @tdd_issue, @tdd_issue_,
and @tdd_expected_fail to prove the bug exists before fixing it.


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

## Bug Report: [error-handling] — Broad exception in A2aEventQueue.publish ### Severity Assessment - **Impact**: May catch system-level exceptions that should not be caught, potentially hiding critical errors. - **Likelihood**: High, as it catches any exception. - **Priority**: Low ### Location - **File**: `src/cleveragents/a2a/events.py` - **Function/Class**: `A2aEventQueue.publish` - **Lines**: 104-108 ### Description The `except Exception:` in `A2aEventQueue.publish` is too broad. It catches any exception, including system-level exceptions like `SystemExit` and `KeyboardInterrupt`, which might not be desirable. While this might be acceptable for a callback system to prevent one failing callback from stopping the entire event propagation, it's better to catch more specific exceptions. ### Evidence ```python for sub_id, callback in self._subscriptions.items(): try: callback(event) except Exception: logger.exception( "a2a.event.callback_error", subscription_id=sub_id, ) ``` ### Expected Behavior The code should catch more specific exceptions, such as `RuntimeError` or a custom callback execution error, to avoid swallowing critical system-level exceptions. ### Actual Behavior The code catches any exception, which could hide bugs or prevent the application from shutting down gracefully. ### Suggested Fix Replace `except Exception:` with a more specific exception type, or a tuple of specific exception types, that are expected to be raised by the callbacks. ### Category error-handling ### TDD Note After this bug issue is verified, a corresponding Type/Testing issue will be created for TDD. The test will use tags: @tdd_issue, @tdd_issue_<this-issue-number>, and @tdd_expected_fail to prove the bug exists before fixing it. --- **Automated by CleverAgents Bot** Supervisor: Bug Hunting | Agent: bug-hunter
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.

Reference
cleveragents/cleveragents-core#5897
No description provided.