BUG: [error-handling] Inconsistent Error Handling in use_action function in plan.py #3690

Open
opened 2026-04-05 22:11:03 +00:00 by freemo · 0 comments
Owner

Metadata

  • Branch: fix/error-handling-use-action-plan
  • Commit Message: fix(cli): standardize error handling in use_action to consistent typer.Abort pattern
  • Milestone: None (Backlog)
  • Parent Epic: #362

Background

The use_action function in src/cleveragents/cli/commands/plan.py (lines 1598–1936) contains multiple try...except blocks that handle exceptions inconsistently. Some exceptions are caught and re-raised as typer.Abort, while others are silently printed to the console without aborting. This produces confusing and unpredictable UX — the CLI may silently continue after an error in some code paths, or exit with no non-zero exit code in others.

Current Behavior

Different exception types in use_action are handled via different mechanisms:

except ActionNotAvailableError as e:
    console.print(f"[red]Action not available:[/red] {e}")
    raise typer.Abort() from e
except ValidationError as e:
    console.print(f"[red]Validation Error:[/red] {e.message}")
    raise typer.Abort() from e
except CleverAgentsError as e:
    console.print(f"[red]Error:[/red] {e.message}")
    raise typer.Abort() from e

Some paths only console.print without raising, leading to silent failures and no non-zero exit code.

Expected Behavior

All exceptions in use_action should be handled consistently:

  • A clear, informative error message is printed to the console.
  • The CLI exits with a non-zero exit code on any error.
  • A single, unified error-handling mechanism is used throughout the function.

Subtasks

  • Audit all try...except blocks in use_action (lines 1598–1936) and catalogue every exception handler
  • Identify handlers that do not raise typer.Abort() or otherwise exit with a non-zero code
  • Refactor all handlers to use a consistent pattern: console.print(...) followed by raise typer.Abort() from e
  • Ensure error messages are clear and informative for each exception type
  • Add or update unit tests covering each exception path in use_action
  • Verify all nox stages pass after refactor

Definition of Done

  • All try...except blocks in use_action use a single, consistent error-handling pattern
  • CLI exits with a non-zero exit code for every error path in use_action
  • Error messages are clear and informative for each exception type
  • Unit tests cover all exception paths in use_action
  • All nox stages pass
  • Coverage >= 97%

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

## Metadata - **Branch**: `fix/error-handling-use-action-plan` - **Commit Message**: `fix(cli): standardize error handling in use_action to consistent typer.Abort pattern` - **Milestone**: None (Backlog) - **Parent Epic**: #362 ## Background The `use_action` function in `src/cleveragents/cli/commands/plan.py` (lines 1598–1936) contains multiple `try...except` blocks that handle exceptions inconsistently. Some exceptions are caught and re-raised as `typer.Abort`, while others are silently printed to the console without aborting. This produces confusing and unpredictable UX — the CLI may silently continue after an error in some code paths, or exit with no non-zero exit code in others. ## Current Behavior Different exception types in `use_action` are handled via different mechanisms: ```python except ActionNotAvailableError as e: console.print(f"[red]Action not available:[/red] {e}") raise typer.Abort() from e except ValidationError as e: console.print(f"[red]Validation Error:[/red] {e.message}") raise typer.Abort() from e except CleverAgentsError as e: console.print(f"[red]Error:[/red] {e.message}") raise typer.Abort() from e ``` Some paths only `console.print` without raising, leading to silent failures and no non-zero exit code. ## Expected Behavior All exceptions in `use_action` should be handled consistently: - A clear, informative error message is printed to the console. - The CLI exits with a non-zero exit code on any error. - A single, unified error-handling mechanism is used throughout the function. ## Subtasks - [ ] Audit all `try...except` blocks in `use_action` (lines 1598–1936) and catalogue every exception handler - [ ] Identify handlers that do not raise `typer.Abort()` or otherwise exit with a non-zero code - [ ] Refactor all handlers to use a consistent pattern: `console.print(...)` followed by `raise typer.Abort() from e` - [ ] Ensure error messages are clear and informative for each exception type - [ ] Add or update unit tests covering each exception path in `use_action` - [ ] Verify all nox stages pass after refactor ## Definition of Done - [ ] All `try...except` blocks in `use_action` use a single, consistent error-handling pattern - [ ] CLI exits with a non-zero exit code for every error path in `use_action` - [ ] Error messages are clear and informative for each exception type - [ ] Unit tests cover all exception paths in `use_action` - [ ] All nox stages pass - [ ] Coverage >= 97% > **Backlog note:** This issue was discovered during autonomous operation > on milestone v3.6.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: Bug Hunting | 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#3690
No description provided.