BUG-HUNT: [error-handling] Overly broad exception handling in devcontainer cleanup #3137

Open
opened 2026-04-05 06:44:35 +00:00 by freemo · 2 comments
Owner

Bug Report: [error-handling] — Overly broad exception handling in devcontainer cleanup

Severity Assessment

  • Impact: May mask recurring problems in the devcontainer cleanup process, leading to resource leaks or other side effects that are difficult to trace.
  • Likelihood: Medium, as it depends on the frequency of errors during cleanup.
  • Priority: Medium

Location

  • File: src/cleveragents/a2a/facade.py
  • Function/Class: _cleanup_session_devcontainers
  • Lines: 362-366

Description

The _cleanup_session_devcontainers function in A2aLocalFacade uses a broad except Exception clause to catch any and all errors that might occur during the devcontainer cleanup process. While the intention is to prevent cleanup failures from interrupting the session closing process, this approach can hide persistent issues. For example, if there is a recurring problem with stopping devcontainers, this broad exception handler will prevent the issue from being surfaced, potentially leading to resource leaks.

Evidence

        except Exception:
            logger.warning(
                "a2a.session.close.devcontainer_cleanup_failed",
                session_id=session_id,
                exc_info=True,
            )

Expected Behavior

The exception handling should be more specific, catching only the expected errors that can occur during devcontainer cleanup. This would allow unexpected errors to propagate, making them visible and easier to debug.

Actual Behavior

All exceptions are caught and logged as a warning, which might not be sufficient for critical errors.

Suggested Fix

Instead of catching Exception, catch more specific exceptions that are expected to be raised by the CleanupService. If the CleanupService can raise a variety of exceptions, consider defining a custom base exception for cleanup errors.

Category

error-handling

Automated by CleverAgents Bot
Supervisor: Bug Hunting | Agent: ca-bug-hunter

## Bug Report: [error-handling] — Overly broad exception handling in devcontainer cleanup ### Severity Assessment - **Impact**: May mask recurring problems in the devcontainer cleanup process, leading to resource leaks or other side effects that are difficult to trace. - **Likelihood**: Medium, as it depends on the frequency of errors during cleanup. - **Priority**: Medium ### Location - **File**: `src/cleveragents/a2a/facade.py` - **Function/Class**: `_cleanup_session_devcontainers` - **Lines**: 362-366 ### Description The `_cleanup_session_devcontainers` function in `A2aLocalFacade` uses a broad `except Exception` clause to catch any and all errors that might occur during the devcontainer cleanup process. While the intention is to prevent cleanup failures from interrupting the session closing process, this approach can hide persistent issues. For example, if there is a recurring problem with stopping devcontainers, this broad exception handler will prevent the issue from being surfaced, potentially leading to resource leaks. ### Evidence ```python except Exception: logger.warning( "a2a.session.close.devcontainer_cleanup_failed", session_id=session_id, exc_info=True, ) ``` ### Expected Behavior The exception handling should be more specific, catching only the expected errors that can occur during devcontainer cleanup. This would allow unexpected errors to propagate, making them visible and easier to debug. ### Actual Behavior All exceptions are caught and logged as a warning, which might not be sufficient for critical errors. ### Suggested Fix Instead of catching `Exception`, catch more specific exceptions that are expected to be raised by the `CleanupService`. If the `CleanupService` can raise a variety of exceptions, consider defining a custom base exception for cleanup errors. ### Category error-handling --- **Automated by CleverAgents Bot** Supervisor: Bug Hunting | Agent: ca-bug-hunter
Author
Owner

Issue triaged by project owner:

  • State: Verified
  • Priority: Low (the broad except Exception in devcontainer cleanup is a defensive pattern to prevent cleanup failures from interrupting session close. This is a reasonable design choice for cleanup code. The risk of resource leaks is low since devcontainers are ephemeral.)
  • Milestone: v3.7.0 (error handling improvements, appropriate for M8)
  • MoSCoW: Could Have — this is a minor code quality improvement. The cleanup path is inherently best-effort, and the current logging at WARNING level is adequate for most debugging scenarios.
  • Parent Epic: #362 (Security & Safety Hardening)

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

Issue triaged by project owner: - **State**: Verified - **Priority**: Low (the broad `except Exception` in devcontainer cleanup is a defensive pattern to prevent cleanup failures from interrupting session close. This is a reasonable design choice for cleanup code. The risk of resource leaks is low since devcontainers are ephemeral.) - **Milestone**: v3.7.0 (error handling improvements, appropriate for M8) - **MoSCoW**: Could Have — this is a minor code quality improvement. The cleanup path is inherently best-effort, and the current logging at WARNING level is adequate for most debugging scenarios. - **Parent Epic**: #362 (Security & 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 08:01:53 +00:00
Author
Owner

Issue triaged by project owner:

  • State: Verified
  • Priority: Backlog → Low (adjusted — error handling improvement)
  • Milestone: v3.7.0 (assigned)
  • MoSCoW: Could Have — Broad exception handling in devcontainer cleanup is a code quality concern per CONTRIBUTING.md error handling guidelines, but the current behavior (logging the exception) is a reasonable defensive pattern for cleanup code. Low priority.

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

Issue triaged by project owner: - **State**: Verified ✅ - **Priority**: Backlog → Low (adjusted — error handling improvement) - **Milestone**: v3.7.0 (assigned) - **MoSCoW**: Could Have — Broad exception handling in devcontainer cleanup is a code quality concern per CONTRIBUTING.md error handling guidelines, but the current behavior (logging the exception) is a reasonable defensive pattern for cleanup code. Low priority. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: ca-project-owner
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#3137
No description provided.