Files
cleveragents-core/features/tdd_session_create_suppress_exception.feature
T
HAL9000 2d519182ca fix(cli): log suppressed facade dispatch exceptions in session create
Replace the silent contextlib.suppress(Exception) block in the session
create command with a try/except that logs at WARNING level with exc_info.

Previously, any exception raised by _facade_dispatch() during session
creation was silently discarded with no logging, making it impossible to
diagnose failures in the facade layer (e.g. A2A bootstrap unavailable,
programming errors, infrastructure issues).

The fix keeps session creation non-fatal (the session is already persisted
before the facade call) while ensuring the exception is visible in logs:

    try:
        _facade_dispatch(session.create, {...})
    except Exception as _exc:
        _log.warning(
            session_create_facade_dispatch_failed,
            extra={"session_id": ..., "error": str(_exc)},
            exc_info=True,
        )

Also includes the TDD regression test from issue #10414 (PR #10749) with
@tdd_expected_fail removed, since the fix is now applied. The test verifies
that a WARNING log entry is emitted when _facade_dispatch() raises and that
session creation still exits 0.

ISSUES CLOSED: #10433
2026-05-07 19:14:53 +00:00

26 lines
1.3 KiB
Gherkin

@tdd_issue @tdd_issue_10414
Feature: TDD Issue #10414 — session create silently suppresses facade dispatch exceptions without logging
As a developer debugging a session creation failure
I want exceptions from _facade_dispatch() to be logged at WARNING level
So that I can diagnose why the facade layer failed without silent data loss
The ``session create`` command in
``src/cleveragents/cli/commands/session.py`` previously used
``contextlib.suppress(Exception)`` to silently discard ALL exceptions
raised by ``_facade_dispatch()``. There was no logging call before or
after the suppress block, making it impossible to diagnose failures in
the facade layer.
The fix replaces the suppress block with a ``try/except Exception`` that
calls ``_log.warning(..., exc_info=True)`` so that the exception is
recorded but the session creation remains non-fatal.
See CONTRIBUTING.md > Bug Fix Workflow > TDD Issue Test Tags.
@tdd_issue @tdd_issue_10414
Scenario: Bug #10414 — session create logs a warning when facade dispatch raises
Given a session create command with a mocked session service
And the facade dispatch is patched to raise a RuntimeError
When I invoke the session create command via the CLI runner
Then a WARNING log entry should have been emitted for the facade dispatch failure