BUG-HUNT: [error-handling] Overly broad except Exception: patterns in CLI command modules mask critical errors #7039

Open
opened 2026-04-10 07:22:12 +00:00 by HAL9000 · 1 comment
Owner

Background

Multiple CLI command modules use bare except Exception: pass patterns that silently swallow all exceptions, including critical ones. This directly violates the project's error handling guidelines (CONTRIBUTING.md: "Do not suppress errors. Let exceptions propagate to top-level execution. Only catch exceptions when you can meaningfully handle them.") and makes debugging extremely difficult when real failures occur.

The affected modules are core CLI command handlers — plan.py, actor.py, and resource.py — which are high-traffic code paths exercised on every CLI invocation.

Current Behavior

The following locations contain broad except Exception: pass (or equivalent) patterns that silently discard all exceptions:

src/cleveragents/cli/commands/plan.py — Lines 101, 1374, 1383, 1431, 1440, 1664

# plan.py line 101 — silently swallows ALL exceptions from facade dispatch:
try:
    facade = get_facade()
    request = A2aRequest(method=operation, params=params)
    facade.dispatch(request)
except Exception:
    pass  # Critical errors (DB failures, network errors, etc.) are lost here

src/cleveragents/cli/commands/actor.py — Lines 234, 252, 260

# actor.py line 252 — defensive pattern with no logging:
except Exception:  # pragma: no cover - defensive; DB may be unavailable
    pass

src/cleveragents/cli/commands/resource.py — Lines 735, 1410

Expected Behavior

CLI commands should:

  1. Catch only specific, known exception types that can be meaningfully handled locally
  2. For defensive/cleanup patterns, at minimum log the exception at WARNING or ERROR level before suppressing
  3. Re-raise unexpected exceptions with proper context so they propagate to the top-level error handler
  4. Never use bare except Exception: pass — this is a silent failure anti-pattern

Acceptance Criteria

  • All except Exception: pass occurrences in the three affected files are replaced with either:
    • Specific exception types (e.g., except (DatabaseError, ConnectionError):) with appropriate handling, or
    • Logged suppression: except Exception: logger.warning("...", exc_info=True) for genuinely defensive patterns
  • No new bare except Exception: pass patterns are introduced
  • Existing test coverage is maintained or improved
  • All nox stages pass

Supporting Information

  • Related to #3155 (Refactor: Replace broad exception handling with specific exception types) — this issue is a specific, high-severity instance of that broader codebase-wide problem, scoped to the CLI command layer
  • CONTRIBUTING.md Error Handling section: "CRITICAL: Do not suppress errors. Let exceptions propagate to top-level execution."
  • Fail-Fast Principles: "No Silent Failures, Explicit Over Implicit"

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

Metadata

  • Branch: bugfix/broad-exception-handling-cli-commands
  • Commit Message: fix(cli): replace broad except Exception patterns in plan, actor, and resource commands
  • Milestone: (none — backlog)
  • Parent Epic: #5203

Subtasks

  • Audit all except Exception occurrences in src/cleveragents/cli/commands/plan.py (lines 101, 1374, 1383, 1431, 1440, 1664)
  • Audit all except Exception occurrences in src/cleveragents/cli/commands/actor.py (lines 234, 252, 260)
  • Audit all except Exception occurrences in src/cleveragents/cli/commands/resource.py (lines 735, 1410)
  • For each occurrence: determine the correct specific exception type(s) or add logging before suppression
  • Write TDD issue (Type/Testing, @tdd_expected_fail) per Bug Fix Workflow
  • Implement fixes on bugfix/ branch
  • Remove @tdd_expected_fail tags once fixes are in place
  • Update documentation if any public-facing error messages change

Definition of Done

  • All identified except Exception: pass patterns replaced with specific types or logged suppression
  • TDD test exists with @tdd_issue and @tdd_issue_<N> tags (permanent regression guard)
  • @tdd_expected_fail tag removed from TDD tests after fix is applied
  • No new bare except Exception: pass patterns introduced
  • All nox stages pass
  • Coverage >= 97%

Automated by CleverAgents Bot
Supervisor: error-handling | Agent: new-issue-creator

## Background Multiple CLI command modules use bare `except Exception: pass` patterns that silently swallow all exceptions, including critical ones. This directly violates the project's error handling guidelines (CONTRIBUTING.md: "Do not suppress errors. Let exceptions propagate to top-level execution. Only catch exceptions when you can meaningfully handle them.") and makes debugging extremely difficult when real failures occur. The affected modules are core CLI command handlers — `plan.py`, `actor.py`, and `resource.py` — which are high-traffic code paths exercised on every CLI invocation. ## Current Behavior The following locations contain broad `except Exception: pass` (or equivalent) patterns that silently discard all exceptions: **`src/cleveragents/cli/commands/plan.py`** — Lines 101, 1374, 1383, 1431, 1440, 1664 ```python # plan.py line 101 — silently swallows ALL exceptions from facade dispatch: try: facade = get_facade() request = A2aRequest(method=operation, params=params) facade.dispatch(request) except Exception: pass # Critical errors (DB failures, network errors, etc.) are lost here ``` **`src/cleveragents/cli/commands/actor.py`** — Lines 234, 252, 260 ```python # actor.py line 252 — defensive pattern with no logging: except Exception: # pragma: no cover - defensive; DB may be unavailable pass ``` **`src/cleveragents/cli/commands/resource.py`** — Lines 735, 1410 ## Expected Behavior CLI commands should: 1. Catch only specific, known exception types that can be meaningfully handled locally 2. For defensive/cleanup patterns, at minimum log the exception at `WARNING` or `ERROR` level before suppressing 3. Re-raise unexpected exceptions with proper context so they propagate to the top-level error handler 4. Never use bare `except Exception: pass` — this is a silent failure anti-pattern ## Acceptance Criteria - All `except Exception: pass` occurrences in the three affected files are replaced with either: - Specific exception types (e.g., `except (DatabaseError, ConnectionError):`) with appropriate handling, or - Logged suppression: `except Exception: logger.warning("...", exc_info=True)` for genuinely defensive patterns - No new bare `except Exception: pass` patterns are introduced - Existing test coverage is maintained or improved - All `nox` stages pass ## Supporting Information - Related to #3155 (Refactor: Replace broad exception handling with specific exception types) — this issue is a specific, high-severity instance of that broader codebase-wide problem, scoped to the CLI command layer - CONTRIBUTING.md Error Handling section: "CRITICAL: Do not suppress errors. Let exceptions propagate to top-level execution." - Fail-Fast Principles: "No Silent Failures, Explicit Over Implicit" > **Backlog note:** This issue was discovered during autonomous operation > on milestone v3.7.0. It does not block milestone completion and has been > placed in the backlog for human review and future milestone assignment. ## Metadata - **Branch**: `bugfix/broad-exception-handling-cli-commands` - **Commit Message**: `fix(cli): replace broad except Exception patterns in plan, actor, and resource commands` - **Milestone**: *(none — backlog)* - **Parent Epic**: #5203 ## Subtasks - [ ] Audit all `except Exception` occurrences in `src/cleveragents/cli/commands/plan.py` (lines 101, 1374, 1383, 1431, 1440, 1664) - [ ] Audit all `except Exception` occurrences in `src/cleveragents/cli/commands/actor.py` (lines 234, 252, 260) - [ ] Audit all `except Exception` occurrences in `src/cleveragents/cli/commands/resource.py` (lines 735, 1410) - [ ] For each occurrence: determine the correct specific exception type(s) or add logging before suppression - [ ] Write TDD issue (`Type/Testing`, `@tdd_expected_fail`) per Bug Fix Workflow - [ ] Implement fixes on `bugfix/` branch - [ ] Remove `@tdd_expected_fail` tags once fixes are in place - [ ] Update documentation if any public-facing error messages change ## Definition of Done - [ ] All identified `except Exception: pass` patterns replaced with specific types or logged suppression - [ ] TDD test exists with `@tdd_issue` and `@tdd_issue_<N>` tags (permanent regression guard) - [ ] `@tdd_expected_fail` tag removed from TDD tests after fix is applied - [ ] No new bare `except Exception: pass` patterns introduced - [ ] All nox stages pass - [ ] Coverage >= 97% --- **Automated by CleverAgents Bot** Supervisor: error-handling | Agent: new-issue-creator
Author
Owner

Verified — Bug: overly broad except Exception patterns in CLI modules mask critical errors. MoSCoW: Should-have. Priority: High.


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

✅ **Verified** — Bug: overly broad except Exception patterns in CLI modules mask critical errors. MoSCoW: Should-have. Priority: High. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: project-owner-pool-supervisor
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#7039
No description provided.