BUG-HUNT: [error-handling] Suppressed RuntimeError in EventBusBridge can hide event publishing failures #3091

Open
opened 2026-04-05 05:55:36 +00:00 by freemo · 2 comments
Owner

Metadata

  • Branch: fix/error-handling-event-bus-bridge-suppress-runtime-error
  • Commit Message: fix(a2a): replace broad RuntimeError suppression in EventBusBridge with explicit queue-closed guard
  • Milestone: Backlog
  • Parent Epic: #933

Bug Report: [error-handling] — Suppressed RuntimeError in EventBusBridge can hide event publishing failures

Severity Assessment

  • Impact: Event propagation can fail silently, leading to inconsistent state and behavior in systems that rely on these events.
  • Likelihood: Low. This is most likely to occur during shutdown, but could also be triggered by other unexpected RuntimeError exceptions.
  • Priority: Medium

Location

  • File: src/cleveragents/a2a/events.py
  • Function/Class: EventBusBridge._on_domain_event
  • Lines: 310-311

Description

The _on_domain_event method in src/cleveragents/a2a/events.py uses contextlib.suppress(RuntimeError) when publishing events to the A2aEventQueue. The publish method of the event queue is designed to raise a RuntimeError if it is called on a closed queue.

While this prevents errors when domain events are received during or after shutdown, it also means that any other RuntimeError that might occur within the publish method will also be silently ignored. This could mask other problems and lead to a situation where events are not being published without any clear indication of a failure.

Evidence

        import contextlib

        with contextlib.suppress(RuntimeError):
            self._event_queue.publish(a2a_event)

Expected Behavior

The exception handling should be more specific. If the intention is to ignore errors only when the queue is closed, the code should explicitly check the is_closed property of the queue before attempting to publish.

Actual Behavior

A broad RuntimeError is suppressed, which could hide legitimate errors and lead to silent failures in event publishing.

Suggested Fix

Check if the queue is closed before publishing, rather than suppressing the RuntimeError.

        if not self._event_queue.is_closed:
            self._event_queue.publish(a2a_event)

This makes the intention of the code clearer and avoids suppressing other potential RuntimeError exceptions.

Category

error-handling

Subtasks

  • Inspect EventBusBridge._on_domain_event in src/cleveragents/a2a/events.py (lines 310-311) to confirm the broad contextlib.suppress(RuntimeError) usage
  • Verify that A2aEventQueue exposes an is_closed property (or equivalent guard) that can be used instead
  • Replace contextlib.suppress(RuntimeError) with an explicit if not self._event_queue.is_closed: guard
  • Update or add Behave unit tests in features/ to cover the case where the queue is closed (no publish attempted) and where it is open (publish proceeds normally)
  • Ensure all nox quality gates pass (nox -e lint, nox -e typecheck, nox -e unit_tests, nox -e coverage_report)

Definition of Done

  • EventBusBridge._on_domain_event no longer uses contextlib.suppress(RuntimeError)
  • The fix uses an explicit closed-queue guard so only the intended shutdown scenario is handled silently
  • Any other RuntimeError from publish propagates correctly and is not swallowed
  • Behave unit tests cover both the closed-queue and open-queue paths
  • All nox stages pass
  • Coverage >= 97%

Backlog note: This issue was discovered during autonomous operation
on milestone v3.4.0. It does not block milestone completion and has been
placed in the backlog for human review and future milestone assignment.


Automated by CleverAgents Bot
Supervisor: Bug Hunting | Agent: ca-new-issue-creator

## Metadata - **Branch**: `fix/error-handling-event-bus-bridge-suppress-runtime-error` - **Commit Message**: `fix(a2a): replace broad RuntimeError suppression in EventBusBridge with explicit queue-closed guard` - **Milestone**: Backlog - **Parent Epic**: #933 ## Bug Report: [error-handling] — Suppressed `RuntimeError` in `EventBusBridge` can hide event publishing failures ### Severity Assessment - **Impact**: Event propagation can fail silently, leading to inconsistent state and behavior in systems that rely on these events. - **Likelihood**: Low. This is most likely to occur during shutdown, but could also be triggered by other unexpected `RuntimeError` exceptions. - **Priority**: Medium ### Location - **File**: `src/cleveragents/a2a/events.py` - **Function/Class**: `EventBusBridge._on_domain_event` - **Lines**: 310-311 ### Description The `_on_domain_event` method in `src/cleveragents/a2a/events.py` uses `contextlib.suppress(RuntimeError)` when publishing events to the `A2aEventQueue`. The `publish` method of the event queue is designed to raise a `RuntimeError` if it is called on a closed queue. While this prevents errors when domain events are received during or after shutdown, it also means that any other `RuntimeError` that might occur within the `publish` method will also be silently ignored. This could mask other problems and lead to a situation where events are not being published without any clear indication of a failure. ### Evidence ```python import contextlib with contextlib.suppress(RuntimeError): self._event_queue.publish(a2a_event) ``` ### Expected Behavior The exception handling should be more specific. If the intention is to ignore errors only when the queue is closed, the code should explicitly check the `is_closed` property of the queue before attempting to publish. ### Actual Behavior A broad `RuntimeError` is suppressed, which could hide legitimate errors and lead to silent failures in event publishing. ### Suggested Fix Check if the queue is closed before publishing, rather than suppressing the `RuntimeError`. ```python if not self._event_queue.is_closed: self._event_queue.publish(a2a_event) ``` This makes the intention of the code clearer and avoids suppressing other potential `RuntimeError` exceptions. ### Category error-handling ## Subtasks - [ ] Inspect `EventBusBridge._on_domain_event` in `src/cleveragents/a2a/events.py` (lines 310-311) to confirm the broad `contextlib.suppress(RuntimeError)` usage - [ ] Verify that `A2aEventQueue` exposes an `is_closed` property (or equivalent guard) that can be used instead - [ ] Replace `contextlib.suppress(RuntimeError)` with an explicit `if not self._event_queue.is_closed:` guard - [ ] Update or add Behave unit tests in `features/` to cover the case where the queue is closed (no publish attempted) and where it is open (publish proceeds normally) - [ ] Ensure all nox quality gates pass (`nox -e lint`, `nox -e typecheck`, `nox -e unit_tests`, `nox -e coverage_report`) ## Definition of Done - [ ] `EventBusBridge._on_domain_event` no longer uses `contextlib.suppress(RuntimeError)` - [ ] The fix uses an explicit closed-queue guard so only the intended shutdown scenario is handled silently - [ ] Any other `RuntimeError` from `publish` propagates correctly and is not swallowed - [ ] Behave unit tests cover both the closed-queue and open-queue paths - [ ] All nox stages pass - [ ] Coverage >= 97% > **Backlog note:** This issue was discovered during autonomous operation > on milestone v3.4.0. It does not block milestone completion and has been > placed in the backlog for human review and future milestone assignment. --- **Automated by CleverAgents Bot** Supervisor: Bug Hunting | Agent: ca-new-issue-creator
Author
Owner

Transition performed: Issue #3091 from State/Unverified to State/Verified.

Preconditions:

  • From State/Unverified to State/Verified requires maintainer triage. Preconditions satisfied.

Labels changed:

  • Removed: State/Unverified (ID: 1320)
  • Added: State/Verified (ID: 1321)
  • Other labels remain: Priority/Backlog (ID: 1333), Type/Bug (ID: 1325)

Current labels after transition:

  • State/Verified (1321)
  • Priority/Backlog (1333)
  • Type/Bug (1325)

Notes:

  • No preconditions about Blocked required since target is State/Verified.

If you want to see the raw label IDs in the issue, you can view the issue labels in the UI or via API.


Automated by CleverAgents Bot
Supervisor: Implementation | Agent: ca-issue-state-updater

Transition performed: Issue #3091 from State/Unverified to State/Verified. Preconditions: - From State/Unverified to State/Verified requires maintainer triage. Preconditions satisfied. Labels changed: - Removed: State/Unverified (ID: 1320) - Added: State/Verified (ID: 1321) - Other labels remain: Priority/Backlog (ID: 1333), Type/Bug (ID: 1325) Current labels after transition: - State/Verified (1321) - Priority/Backlog (1333) - Type/Bug (1325) Notes: - No preconditions about Blocked required since target is State/Verified. If you want to see the raw label IDs in the issue, you can view the issue labels in the UI or via API. --- **Automated by CleverAgents Bot** Supervisor: Implementation | Agent: ca-issue-state-updater
freemo added this to the v3.6.0 milestone 2026-04-05 06:18:04 +00:00
Author
Owner

Issue triaged by project owner:

  • State: Verified
  • Priority: Backlog — low likelihood (primarily during shutdown), medium impact
  • Milestone: v3.6.0 (Advanced Concepts & Deferred Features)
  • MoSCoW: Could Have — error handling improvement with low likelihood of triggering; the current behavior is intentional for shutdown scenarios, the fix is a refinement
  • Parent Epic: #933 (A2A Protocol Compliance)

The fix is straightforward (replace contextlib.suppress(RuntimeError) with an explicit is_closed guard) and improves code clarity, but this is not blocking any milestone deliverable.


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

Issue triaged by project owner: - **State**: Verified - **Priority**: Backlog — low likelihood (primarily during shutdown), medium impact - **Milestone**: v3.6.0 (Advanced Concepts & Deferred Features) - **MoSCoW**: Could Have — error handling improvement with low likelihood of triggering; the current behavior is intentional for shutdown scenarios, the fix is a refinement - **Parent Epic**: #933 (A2A Protocol Compliance) The fix is straightforward (replace `contextlib.suppress(RuntimeError)` with an explicit `is_closed` guard) and improves code clarity, but this is not blocking any milestone deliverable. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: ca-project-owner
freemo removed this from the v3.6.0 milestone 2026-04-07 00:19:53 +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.

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