bug(events): LoggingEventBus.emit() handler exception block missing exc_info=True — no traceback logged #1311

Open
opened 2026-04-02 11:04:16 +00:00 by CoreRasurae · 0 comments
Member

Metadata

  • Commit Message: fix(events): add exc_info=True to LoggingEventBus.emit() handler exception block
  • Branch: bugfix/m5-logging-bus-exception-swallow

Background

Discovered during code review of PR #1174 (fix for #988). Issue #988 fixed the identical omission in ReactiveEventBus.emit() — this issue tracks the same pattern in the sibling EventBus protocol implementation.

LoggingEventBus is the other EventBus protocol implementation in the infrastructure/events/ package. While ReactiveEventBus is the production DI registrant (registered as Singleton in the container), LoggingEventBus is used in test contexts and is a protocol-compliant implementation that should behave consistently.

Current Behavior

logging_bus.py:76-83: The handler exception block in LoggingEventBus.emit() logs error_type=type(exc).__name__ and error=str(exc) but does not include exc_info=True. When a subscriber handler fails, the log contains the exception type and message text but no traceback. This is the same class of bug that #988 identified and fixed in ReactiveEventBus.

except Exception as exc:
    _logger.warning(
        "logging_event_handler_failed",
        event_type=event.event_type.value,
        handler=getattr(handler, "__qualname__", repr(handler)),
        error_type=type(exc).__name__,
        error=str(exc),
        # ← no exc_info=True — traceback is lost
    )

Expected Behavior

The handler exception block should include exc_info=True so that structlog forwards the full traceback to the configured log output, consistent with the fix applied to ReactiveEventBus in PR #1174.

Acceptance Criteria

  • LoggingEventBus.emit() handler exception block includes exc_info=True
  • Behavior is consistent with ReactiveEventBus.emit() exception handling (both protocol implementations forward tracebacks)
  • Unit test verifies exc_info appears in the log entry when a handler raises
  • nox passes with coverage >= 97%

Subtasks

  • Add exc_info=True to the _logger.warning() call in LoggingEventBus.emit() handler exception block (src/cleveragents/infrastructure/events/logging_bus.py:77-83)
  • Remove @tdd_expected_fail tag from the corresponding TDD test once fix is applied
  • Update CHANGELOG.md with fix entry
  • Run nox (all default sessions), fix any errors

References

  • Sibling fix: PR #1174 / Issue #988 (ReactiveEventBus)
  • File: src/cleveragents/infrastructure/events/logging_bus.py:76-83
  • Specification: docs/specification.md §Event System — EventBus protocol

Definition of Done

This issue is complete when:

  • All subtasks above are completed and checked off.
  • A Git commit is created where the first line of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details about the implementation.
  • The commit is pushed to the remote on the branch matching the Branch in Metadata exactly.
  • The commit is submitted as a pull request to master, reviewed, and merged before this issue is marked done.
## Metadata - **Commit Message**: `fix(events): add exc_info=True to LoggingEventBus.emit() handler exception block` - **Branch**: `bugfix/m5-logging-bus-exception-swallow` ## Background Discovered during code review of PR #1174 (fix for #988). Issue #988 fixed the identical omission in `ReactiveEventBus.emit()` — this issue tracks the same pattern in the sibling `EventBus` protocol implementation. `LoggingEventBus` is the other `EventBus` protocol implementation in the `infrastructure/events/` package. While `ReactiveEventBus` is the production DI registrant (registered as Singleton in the container), `LoggingEventBus` is used in test contexts and is a protocol-compliant implementation that should behave consistently. ## Current Behavior `logging_bus.py:76-83`: The handler exception block in `LoggingEventBus.emit()` logs `error_type=type(exc).__name__` and `error=str(exc)` but does **not** include `exc_info=True`. When a subscriber handler fails, the log contains the exception type and message text but no traceback. This is the same class of bug that #988 identified and fixed in `ReactiveEventBus`. ```python except Exception as exc: _logger.warning( "logging_event_handler_failed", event_type=event.event_type.value, handler=getattr(handler, "__qualname__", repr(handler)), error_type=type(exc).__name__, error=str(exc), # ← no exc_info=True — traceback is lost ) ``` ## Expected Behavior The handler exception block should include `exc_info=True` so that structlog forwards the full traceback to the configured log output, consistent with the fix applied to `ReactiveEventBus` in PR #1174. ## Acceptance Criteria - [ ] `LoggingEventBus.emit()` handler exception block includes `exc_info=True` - [ ] Behavior is consistent with `ReactiveEventBus.emit()` exception handling (both protocol implementations forward tracebacks) - [ ] Unit test verifies `exc_info` appears in the log entry when a handler raises - [ ] `nox` passes with coverage >= 97% ## Subtasks - [ ] Add `exc_info=True` to the `_logger.warning()` call in `LoggingEventBus.emit()` handler exception block (`src/cleveragents/infrastructure/events/logging_bus.py:77-83`) - [ ] Remove `@tdd_expected_fail` tag from the corresponding TDD test once fix is applied - [ ] Update CHANGELOG.md with fix entry - [ ] Run `nox` (all default sessions), fix any errors ## References - Sibling fix: PR #1174 / Issue #988 (`ReactiveEventBus`) - File: `src/cleveragents/infrastructure/events/logging_bus.py:76-83` - Specification: `docs/specification.md` §Event System — `EventBus` protocol ## Definition of Done This issue is complete when: - All subtasks above are completed and checked off. - A Git commit is created where the **first line** of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details about the implementation. - The commit is pushed to the remote on the branch matching the **Branch** in Metadata exactly. - The commit is submitted as a **pull request** to `master`, reviewed, and **merged** before this issue is marked done.
freemo self-assigned this 2026-04-02 18:45:24 +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.

Dependencies

No dependencies set.

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