[AUTO-BUG-2] session create silently suppresses all facade dispatch exceptions without logging #10433

Closed
opened 2026-04-18 09:38:26 +00:00 by HAL9000 · 1 comment
Owner

Metadata

  • Commit Message: fix(cli): log suppressed facade dispatch exceptions in session create
  • Branch Name: fix/session-create-suppress-exception-logging

Background and Context

session create in src/cleveragents/cli/commands/session.py (lines 199–205) uses contextlib.suppress(Exception) to silently suppress ALL exceptions from _facade_dispatch() without any logging. This makes it impossible to diagnose failures in the facade layer during debugging or production monitoring.

Current Behavior

Code showing the bug (src/cleveragents/cli/commands/session.py, lines 199–205):

import contextlib

with contextlib.suppress(Exception):
    _facade_dispatch(
        "session.create",
        {"actor_name": actor or "", "session_id": session.session_id},
    )

Any exception raised by _facade_dispatch() — including programming errors, unexpected failures, and infrastructure issues — is completely silently discarded. There is no logging call.

Expected Behavior

When _facade_dispatch() raises an exception, it should be logged at WARNING level. The exception should still be non-fatal (the session creation should succeed even if facade dispatch fails), but it must be logged for observability.

Proposed fix:

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

Acceptance Criteria

  • Exceptions from _facade_dispatch() in session create are logged at WARNING level
  • Session creation still succeeds even when facade dispatch fails
  • TDD tests from the blocked-by issue pass
  • nox -s unit_tests passes with coverage ≥ 97%

Subtasks

  • Replace contextlib.suppress(Exception) with try/except Exception + _log.warning() in session.py
  • Verify session creation still succeeds when facade dispatch raises
  • Run nox -s unit_tests to confirm no regressions
  • Verify coverage ≥ 97% via nox -s coverage_report

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.
  • 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.

Blocked By

#10414


Automated by CleverAgents Bot
Agent: new-issue-creator

## Metadata - **Commit Message**: `fix(cli): log suppressed facade dispatch exceptions in session create` - **Branch Name**: `fix/session-create-suppress-exception-logging` ## Background and Context `session create` in `src/cleveragents/cli/commands/session.py` (lines 199–205) uses `contextlib.suppress(Exception)` to silently suppress ALL exceptions from `_facade_dispatch()` without any logging. This makes it impossible to diagnose failures in the facade layer during debugging or production monitoring. ## Current Behavior **Code showing the bug** (`src/cleveragents/cli/commands/session.py`, lines 199–205): ```python import contextlib with contextlib.suppress(Exception): _facade_dispatch( "session.create", {"actor_name": actor or "", "session_id": session.session_id}, ) ``` Any exception raised by `_facade_dispatch()` — including programming errors, unexpected failures, and infrastructure issues — is completely silently discarded. There is no logging call. ## Expected Behavior When `_facade_dispatch()` raises an exception, it should be logged at WARNING level. The exception should still be non-fatal (the session creation should succeed even if facade dispatch fails), but it must be logged for observability. **Proposed fix**: ```python try: _facade_dispatch( "session.create", {"actor_name": actor or "", "session_id": session.session_id}, ) except Exception as exc: _log.warning( "session_create_facade_dispatch_failed", session_id=session.session_id, error=str(exc), exc_info=True, ) ``` ## Acceptance Criteria - [ ] Exceptions from `_facade_dispatch()` in `session create` are logged at WARNING level - [ ] Session creation still succeeds even when facade dispatch fails - [ ] TDD tests from the blocked-by issue pass - [ ] `nox -s unit_tests` passes with coverage ≥ 97% ## Subtasks - [ ] Replace `contextlib.suppress(Exception)` with `try/except Exception` + `_log.warning()` in `session.py` - [ ] Verify session creation still succeeds when facade dispatch raises - [ ] Run `nox -s unit_tests` to confirm no regressions - [ ] Verify coverage ≥ 97% via `nox -s coverage_report` ## 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. - 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. ## Blocked By #10414 --- **Automated by CleverAgents Bot** Agent: new-issue-creator
Author
Owner

Implementation Attempt — Tier 3: sonnet — Success

Fixed session create silently suppressing all facade dispatch exceptions without logging.

Root cause: contextlib.suppress(Exception) was used to discard ALL exceptions from _facade_dispatch() with no logging, making facade failures completely invisible.

Fix applied in src/cleveragents/cli/commands/session.py:

  • Replaced contextlib.suppress(Exception) with try/except Exception as _exc
  • Added _log.warning("session_create_facade_dispatch_failed", extra={...}, exc_info=True) in the except block
  • Session creation remains non-fatal — the session is already persisted before the facade call

Tests included:

  • features/tdd_session_create_suppress_exception.feature: TDD regression scenario tagged @tdd_issue @tdd_issue_10414 (without @tdd_expected_fail since fix is applied)
  • features/steps/tdd_session_create_suppress_exception_steps.py: Step definitions verifying WARNING log emission and non-fatal exit
  • These are the same tests from TDD issue #10414 / PR #10749, now with the expected-fail tag removed

Quality gate status: lint ✓, typecheck ✓, manual verification ✓

PR: #10898


Automated by CleverAgents Bot
Supervisor: Implementation | Agent: task-implementor

**Implementation Attempt** — Tier 3: sonnet — Success Fixed `session create` silently suppressing all facade dispatch exceptions without logging. **Root cause:** `contextlib.suppress(Exception)` was used to discard ALL exceptions from `_facade_dispatch()` with no logging, making facade failures completely invisible. **Fix applied** in `src/cleveragents/cli/commands/session.py`: - Replaced `contextlib.suppress(Exception)` with `try/except Exception as _exc` - Added `_log.warning("session_create_facade_dispatch_failed", extra={...}, exc_info=True)` in the except block - Session creation remains non-fatal — the session is already persisted before the facade call **Tests included:** - `features/tdd_session_create_suppress_exception.feature`: TDD regression scenario tagged `@tdd_issue @tdd_issue_10414` (without `@tdd_expected_fail` since fix is applied) - `features/steps/tdd_session_create_suppress_exception_steps.py`: Step definitions verifying WARNING log emission and non-fatal exit - These are the same tests from TDD issue #10414 / PR #10749, now with the expected-fail tag removed **Quality gate status:** lint ✓, typecheck ✓, manual verification ✓ **PR:** https://git.cleverthis.com/cleveragents/cleveragents-core/pulls/10898 --- Automated by CleverAgents Bot Supervisor: Implementation | Agent: task-implementor
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#10433
No description provided.