BUG-HUNT: [error-handling] Suppressed exceptions in facade wiring and cleanup #3452

Open
opened 2026-04-05 17:21:41 +00:00 by freemo · 1 comment
Owner

Metadata

  • Branch: fix/error-handling-suppressed-exceptions-facade
  • Commit Message: fix(error-handling): replace suppressed exceptions in facade wiring and cleanup with explicit logging
  • Milestone: Backlog
  • Parent Epic: #362

Bug Report: [error-handling] — Suppressed exceptions in facade wiring and cleanup

Severity Assessment

  • Impact: Failures in service wiring or devcontainer cleanup are silently ignored. This can lead to a partially-functional system or resource leaks that are difficult to debug.
  • Likelihood: Moderate, especially in development or misconfigured environments.
  • Priority: Medium

Location

  • File: src/cleveragents/a2a/cli_bootstrap.py

  • Function/Class: _build_facade

  • Lines: 39-50

  • File: src/cleveragents/a2a/facade.py

  • Function/Class: _cleanup_session_devcontainers

  • Lines: 361-366

Description

The _build_facade function in cli_bootstrap.py uses contextlib.suppress(Exception) to ignore any errors that occur when retrieving services from the dependency injection container. This means that if a service fails to initialize for any reason, the facade will be created in a partially-wired state without any warning or error.

Similarly, the _cleanup_session_devcontainers function in facade.py uses a broad except Exception to catch and log any errors during devcontainer cleanup. While it logs a warning, it might not be prominent enough for a potentially resource-leaking issue.

This violates CONTRIBUTING.md's error-handling standard: "Errors must not be suppressed. Exceptions should propagate to the top-level execution for centralized logging and handling."

Evidence

cli_bootstrap.py:

    with contextlib.suppress(Exception):
        services["plan_lifecycle_service"] = container.plan_lifecycle_service()

    with contextlib.suppress(Exception):
        services["session_service"] = container.session_service()

facade.py:

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

Expected Behavior

  • Service wiring failures during facade construction should at least be logged as warnings, so that developers are aware of configuration or initialization problems.
  • Devcontainer cleanup failures should be handled with more specific exceptions, and potentially retries or more prominent alerts if they persist.

Suggested Fix

  • In _build_facade, replace contextlib.suppress(Exception) with a try...except block that logs a warning with the exception details.
  • In _cleanup_session_devcontainers, catch more specific exceptions if possible, and consider a more robust error handling strategy if devcontainer leaks are a significant risk.

Category

error-handling

Subtasks

  • Replace contextlib.suppress(Exception) in _build_facade (cli_bootstrap.py lines 39-50) with explicit try...except blocks that log a structured warning including the exception details
  • Review _cleanup_session_devcontainers in facade.py (lines 361-366) and replace broad except Exception with more specific exception types where possible
  • Add structured log entries at WARNING level (or higher) for any caught exceptions in both locations so failures are visible in production logs
  • Write BDD unit test scenarios in features/ covering the new warning-log behaviour when service wiring fails
  • Write BDD unit test scenarios covering the devcontainer cleanup failure path
  • Ensure all nox stages pass and coverage remains ≥ 97%

Definition of Done

  • contextlib.suppress(Exception) removed from _build_facade; failures are logged as structured warnings
  • _cleanup_session_devcontainers uses specific exception types (or retains broad catch with clear justification) and logs at an appropriate severity
  • New BDD scenarios added and passing in features/
  • All nox stages pass
  • Coverage >= 97%
  • PR merged to the correct branch with the correct commit message

Backlog note: This issue was discovered during autonomous operation
on milestone v3.3.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-suppressed-exceptions-facade` - **Commit Message**: `fix(error-handling): replace suppressed exceptions in facade wiring and cleanup with explicit logging` - **Milestone**: Backlog - **Parent Epic**: #362 ## Bug Report: [error-handling] — Suppressed exceptions in facade wiring and cleanup ### Severity Assessment - **Impact**: Failures in service wiring or devcontainer cleanup are silently ignored. This can lead to a partially-functional system or resource leaks that are difficult to debug. - **Likelihood**: Moderate, especially in development or misconfigured environments. - **Priority**: Medium ### Location - **File**: `src/cleveragents/a2a/cli_bootstrap.py` - **Function/Class**: `_build_facade` - **Lines**: 39-50 - **File**: `src/cleveragents/a2a/facade.py` - **Function/Class**: `_cleanup_session_devcontainers` - **Lines**: 361-366 ### Description The `_build_facade` function in `cli_bootstrap.py` uses `contextlib.suppress(Exception)` to ignore any errors that occur when retrieving services from the dependency injection container. This means that if a service fails to initialize for any reason, the facade will be created in a partially-wired state without any warning or error. Similarly, the `_cleanup_session_devcontainers` function in `facade.py` uses a broad `except Exception` to catch and log any errors during devcontainer cleanup. While it logs a warning, it might not be prominent enough for a potentially resource-leaking issue. This violates CONTRIBUTING.md's error-handling standard: *"Errors must not be suppressed. Exceptions should propagate to the top-level execution for centralized logging and handling."* ### Evidence `cli_bootstrap.py`: ```python with contextlib.suppress(Exception): services["plan_lifecycle_service"] = container.plan_lifecycle_service() with contextlib.suppress(Exception): services["session_service"] = container.session_service() ``` `facade.py`: ```python except Exception: logger.warning( "a2a.session.close.devcontainer_cleanup_failed", session_id=session_id, exc_info=True, ) ``` ### Expected Behavior - Service wiring failures during facade construction should at least be logged as warnings, so that developers are aware of configuration or initialization problems. - Devcontainer cleanup failures should be handled with more specific exceptions, and potentially retries or more prominent alerts if they persist. ### Suggested Fix - In `_build_facade`, replace `contextlib.suppress(Exception)` with a `try...except` block that logs a warning with the exception details. - In `_cleanup_session_devcontainers`, catch more specific exceptions if possible, and consider a more robust error handling strategy if devcontainer leaks are a significant risk. ### Category error-handling ## Subtasks - [ ] Replace `contextlib.suppress(Exception)` in `_build_facade` (`cli_bootstrap.py` lines 39-50) with explicit `try...except` blocks that log a structured warning including the exception details - [ ] Review `_cleanup_session_devcontainers` in `facade.py` (lines 361-366) and replace broad `except Exception` with more specific exception types where possible - [ ] Add structured log entries at `WARNING` level (or higher) for any caught exceptions in both locations so failures are visible in production logs - [ ] Write BDD unit test scenarios in `features/` covering the new warning-log behaviour when service wiring fails - [ ] Write BDD unit test scenarios covering the devcontainer cleanup failure path - [ ] Ensure all nox stages pass and coverage remains ≥ 97% ## Definition of Done - [ ] `contextlib.suppress(Exception)` removed from `_build_facade`; failures are logged as structured warnings - [ ] `_cleanup_session_devcontainers` uses specific exception types (or retains broad catch with clear justification) and logs at an appropriate severity - [ ] New BDD scenarios added and passing in `features/` - [ ] All nox stages pass - [ ] Coverage >= 97% - [ ] PR merged to the correct branch with the correct commit message > **Backlog note:** This issue was discovered during autonomous operation > on milestone v3.3.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
freemo added this to the v3.7.0 milestone 2026-04-05 17:25:14 +00:00
Author
Owner

Issue triaged by project owner:

  • State: Verified
  • Priority: Backlog (confirmed) — Suppressed exceptions in facade wiring. Code quality improvement.
  • Milestone: v3.7.0 (assigned — code quality hardening)
  • Story Points: 2 (S) — Replace contextlib.suppress with explicit try/except + logging
  • MoSCoW: Could Have — The facade works in practice; this improves debuggability.
  • 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**: Backlog (confirmed) — Suppressed exceptions in facade wiring. Code quality improvement. - **Milestone**: v3.7.0 (assigned — code quality hardening) - **Story Points**: 2 (S) — Replace `contextlib.suppress` with explicit try/except + logging - **MoSCoW**: Could Have — The facade works in practice; this improves debuggability. - **Parent Epic**: #362 (Security & Safety Hardening) --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: ca-project-owner
freemo removed this from the v3.7.0 milestone 2026-04-06 23:49:00 +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#3452
No description provided.