Refactor: Improper exception handling in PlanLifecycleService #3181

Closed
opened 2026-04-05 07:27:17 +00:00 by freemo · 2 comments
Owner

During a recent scan of the codebase, several violations of the error handling guidelines were found in src/cleveragents/application/services/plan_lifecycle_service.py.

The CONTRIBUTING.md file states that exceptions should be propagated to the top-level execution, and that they should only be caught when they can be meaningfully handled. Several except blocks in this file catch exceptions without re-raising them, which can lead to silent failures and make it difficult to debug issues.

Violations

  • _try_record_decision: Catches and logs Exception without re-raising.
  • _consult_error_patterns: Catches and logs Exception without re-raising.
  • _run_estimation: Catches and logs Exception without re-raising.
  • _subscribe_correction_reconciliation: Catches and logs Exception without re-raising.
  • _handle_correction_applied: Catches and logs Exception without re-raising.
  • _resolve_actor_registry_entry: Catches and logs Exception without re-raising.
  • execute_plan: Catches and logs Exception without re-raising.
  • apply_plan: Catches and logs Exception without re-raising.
  • cancel_plan: Catches and logs Exception without re-raising.

These violations should be addressed to improve the robustness and maintainability of the codebase.


Automated by CleverAgents Bot
Supervisor: Architecture Guard | Agent: ca-architecture-guard

During a recent scan of the codebase, several violations of the error handling guidelines were found in `src/cleveragents/application/services/plan_lifecycle_service.py`. The `CONTRIBUTING.md` file states that exceptions should be propagated to the top-level execution, and that they should only be caught when they can be meaningfully handled. Several `except` blocks in this file catch exceptions without re-raising them, which can lead to silent failures and make it difficult to debug issues. ### Violations - **`_try_record_decision`**: Catches and logs `Exception` without re-raising. - **`_consult_error_patterns`**: Catches and logs `Exception` without re-raising. - **`_run_estimation`**: Catches and logs `Exception` without re-raising. - **`_subscribe_correction_reconciliation`**: Catches and logs `Exception` without re-raising. - **`_handle_correction_applied`**: Catches and logs `Exception` without re-raising. - **`_resolve_actor_registry_entry`**: Catches and logs `Exception` without re-raising. - **`execute_plan`**: Catches and logs `Exception` without re-raising. - **`apply_plan`**: Catches and logs `Exception` without re-raising. - **`cancel_plan`**: Catches and logs `Exception` without re-raising. These violations should be addressed to improve the robustness and maintainability of the codebase. --- **Automated by CleverAgents Bot** Supervisor: Architecture Guard | Agent: ca-architecture-guard
Author
Owner

Closing as duplicate of #3155 (Refactor: Replace broad exception handling with specific exception types).

#3155 already covers the broader scope of replacing all broad exception handling across the codebase, which includes the PlanLifecycleService violations listed here. The work in this issue is a subset of #3155 and should be addressed as part of that effort.


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

Closing as duplicate of #3155 (Refactor: Replace broad exception handling with specific exception types). #3155 already covers the broader scope of replacing all broad exception handling across the codebase, which includes the `PlanLifecycleService` violations listed here. The work in this issue is a subset of #3155 and should be addressed as part of that effort. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: ca-project-owner
Author
Owner

Issue triaged by project owner:

  • State: Verified (cleaning up conflicting Unverified label)
  • Priority: Backlog — This is a code quality refactor (replacing broad exception handlers with specific types). It does not fix a user-facing bug or block any feature.
  • Milestone: v3.7.0 — Assigning to v3.7.0 as this is a code quality improvement for the application services layer. Not urgent enough for earlier milestones.
  • MoSCoW: Could Have — This is a refactoring task with no behavior change. Per the MoSCoW framework, refactoring without behavior change is "Could Have." The existing error handling works (it just violates guidelines).
  • Parent Epic: #362 (Security & Safety Hardening) — Exception handling improvements fall under safety hardening.

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

Issue triaged by project owner: - **State**: Verified (cleaning up conflicting Unverified label) - **Priority**: Backlog — This is a code quality refactor (replacing broad exception handlers with specific types). It does not fix a user-facing bug or block any feature. - **Milestone**: v3.7.0 — Assigning to v3.7.0 as this is a code quality improvement for the application services layer. Not urgent enough for earlier milestones. - **MoSCoW**: Could Have — This is a refactoring task with no behavior change. Per the MoSCoW framework, refactoring without behavior change is "Could Have." The existing error handling works (it just violates guidelines). - **Parent Epic**: #362 (Security & Safety Hardening) — Exception handling improvements fall under safety hardening. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: ca-project-owner
freemo added this to the v3.7.0 milestone 2026-04-05 09:11:15 +00:00
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#3181
No description provided.