UAT: Silent exception suppression in session create command hides actor detail errors #3863

Open
opened 2026-04-06 07:01:06 +00:00 by freemo · 0 comments
Owner

Metadata

  • Branch: fix/session-create-silent-exception-suppression
  • Commit Message: fix(cli): replace bare except pass in session create with structured debug logging
  • Milestone: (backlog — see note below)
  • Parent Epic: #362

Bug Report

Feature Area: Error Handling and Resilience
Severity: Medium
Found by: UAT automated testing

What Was Tested

The create_session command in src/cleveragents/cli/commands/session.py (around line 247) was analyzed for compliance with the CONTRIBUTING.md exception propagation rules.

Expected Behavior (from CONTRIBUTING.md)

Errors must never be suppressed. Exceptions should be allowed to propagate up to the top-level execution handler.
Catch-all exception handlers should not be used unless they re-raise the exception.
Exceptions should only be caught when there is a meaningful way to handle them.

Actual Behavior

The session create command silently swallows exceptions when fetching actor details with a bare except Exception: pass:

# src/cleveragents/cli/commands/session.py lines 240-248
            try:
                actor_obj = actor_service.get_actor(actor_name)
                actor_details = (
                    f"[blue]Provider:[/blue] {actor_obj.provider}\n"
                    ...
                )
                console.print(Panel(actor_details, title="Actor Details", expand=False))
            except Exception:
                pass  # Actor details unavailable  <-- VIOLATION

Why This Is a Problem

  1. No logging: If actor_service.get_actor() fails (e.g., database error, actor not found), there is zero diagnostic information.
  2. Violates CONTRIBUTING.md: The rule states exceptions should only be caught when there is a meaningful recovery action. A bare pass is not meaningful.
  3. Masks configuration issues: If the actor service is misconfigured or the database is unavailable, this silently hides the problem.
  4. User confusion: The session is created but actor details are silently missing, leaving the user wondering why no actor info is shown.

Replace the bare pass with a debug-level log and optionally a user-visible warning:

            except Exception:
                logger.debug(
                    "Failed to fetch actor details for display",
                    actor_name=actor_name,
                    exc_info=True,
                )
                # Optionally: console.print("[dim]Actor details unavailable[/dim]")

Code Location

  • File: src/cleveragents/cli/commands/session.py
  • Lines: ~240-248
  • Function: create_session (or similar session create handler)

Subtasks

  • Locate the bare except Exception: pass block in src/cleveragents/cli/commands/session.py (~line 247)
  • Write a TDD issue-capture Behave scenario tagged @tdd_expected_fail demonstrating the missing log
  • Replace pass with logger.debug(...) including exc_info=True and structured context fields
  • Optionally add a user-visible [dim]Actor details unavailable[/dim] console message
  • Ensure all type annotations remain valid and pass nox -e typecheck
  • Verify the fix passes nox -e lint
  • Remove @tdd_expected_fail tag once the fix is in place and tests pass

Definition of Done

  • No bare except Exception: pass blocks remain in the session create command
  • A logger.debug(...) call with exc_info=True is present in the exception handler
  • A Behave scenario covers the failure path and verifies the debug log is emitted
  • All nox stages pass
  • Coverage >= 97%

Backlog note: This issue was discovered during autonomous operation
on milestone v3.5.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: UAT Testing | Agent: ca-new-issue-creator

## Metadata - **Branch**: `fix/session-create-silent-exception-suppression` - **Commit Message**: `fix(cli): replace bare except pass in session create with structured debug logging` - **Milestone**: *(backlog — see note below)* - **Parent Epic**: #362 ## Bug Report **Feature Area:** Error Handling and Resilience **Severity:** Medium **Found by:** UAT automated testing ### What Was Tested The `create_session` command in `src/cleveragents/cli/commands/session.py` (around line 247) was analyzed for compliance with the CONTRIBUTING.md exception propagation rules. ### Expected Behavior (from CONTRIBUTING.md) > Errors must **never** be suppressed. Exceptions should be allowed to propagate up to the top-level execution handler. > Catch-all exception handlers should not be used unless they re-raise the exception. > Exceptions should only be caught when there is a meaningful way to handle them. ### Actual Behavior The session create command silently swallows exceptions when fetching actor details with a bare `except Exception: pass`: ```python # src/cleveragents/cli/commands/session.py lines 240-248 try: actor_obj = actor_service.get_actor(actor_name) actor_details = ( f"[blue]Provider:[/blue] {actor_obj.provider}\n" ... ) console.print(Panel(actor_details, title="Actor Details", expand=False)) except Exception: pass # Actor details unavailable <-- VIOLATION ``` ### Why This Is a Problem 1. **No logging**: If `actor_service.get_actor()` fails (e.g., database error, actor not found), there is zero diagnostic information. 2. **Violates CONTRIBUTING.md**: The rule states exceptions should only be caught when there is a meaningful recovery action. A bare `pass` is not meaningful. 3. **Masks configuration issues**: If the actor service is misconfigured or the database is unavailable, this silently hides the problem. 4. **User confusion**: The session is created but actor details are silently missing, leaving the user wondering why no actor info is shown. ### Recommended Fix Replace the bare `pass` with a debug-level log and optionally a user-visible warning: ```python except Exception: logger.debug( "Failed to fetch actor details for display", actor_name=actor_name, exc_info=True, ) # Optionally: console.print("[dim]Actor details unavailable[/dim]") ``` ### Code Location - File: `src/cleveragents/cli/commands/session.py` - Lines: ~240-248 - Function: `create_session` (or similar session create handler) ## Subtasks - [ ] Locate the bare `except Exception: pass` block in `src/cleveragents/cli/commands/session.py` (~line 247) - [ ] Write a TDD issue-capture Behave scenario tagged `@tdd_expected_fail` demonstrating the missing log - [ ] Replace `pass` with `logger.debug(...)` including `exc_info=True` and structured context fields - [ ] Optionally add a user-visible `[dim]Actor details unavailable[/dim]` console message - [ ] Ensure all type annotations remain valid and pass `nox -e typecheck` - [ ] Verify the fix passes `nox -e lint` - [ ] Remove `@tdd_expected_fail` tag once the fix is in place and tests pass ## Definition of Done - [ ] No bare `except Exception: pass` blocks remain in the session create command - [ ] A `logger.debug(...)` call with `exc_info=True` is present in the exception handler - [ ] A Behave scenario covers the failure path and verifies the debug log is emitted - [ ] All nox stages pass - [ ] Coverage >= 97% > **Backlog note:** This issue was discovered during autonomous operation > on milestone v3.5.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: UAT Testing | Agent: ca-new-issue-creator
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.

Blocks
#362 Epic: Security & Safety Hardening
cleveragents/cleveragents-core
Reference
cleveragents/cleveragents-core#3863
No description provided.