diff --git a/features/a2a_facade_coverage.feature b/features/a2a_facade_coverage.feature index eaee174d2..a8acf2b5d 100644 --- a/features/a2a_facade_coverage.feature +++ b/features/a2a_facade_coverage.feature @@ -19,11 +19,15 @@ Feature: A2A local facade coverage — uncovered handler and edge-case paths Then the facade-cov response status should be "ok" And the facade-cov response data key "status" should equal "closed" - Scenario: Session close with empty session_id and no service + Scenario: Session close with empty session_id and no service raises ValueError error Given a facade-cov facade with no services When I dispatch facade-cov operation "session.close" with params {"session_id": ""} - Then the facade-cov response status should be "ok" - And the facade-cov response data key "status" should equal "closed" + Then the facade-cov response status should be "error" + + Scenario: Session close with missing session_id key and no service raises ValueError error + Given a facade-cov facade with no services + When I dispatch facade-cov operation "session.close" with params {} + Then the facade-cov response status should be "error" # ------------------------------------------------------------------- # Plan cancel — with service wired (lines 501-502) diff --git a/src/cleveragents/a2a/facade.py b/src/cleveragents/a2a/facade.py index 43be9f4c2..4d0e477f5 100644 --- a/src/cleveragents/a2a/facade.py +++ b/src/cleveragents/a2a/facade.py @@ -354,6 +354,12 @@ class A2aLocalFacade: def _handle_session_close(self, params: dict[str, Any]) -> dict[str, Any]: session_id = params.get("session_id", "") + # Validate session_id BEFORE checking service availability so that + # empty or missing IDs are never silently passed through to + # devcontainer cleanup regardless of whether SessionService is wired. + if not session_id: + raise ValueError("session_id is required") + svc = self._session_service if svc is None: # R7-F4 fix: still run container cleanup even without a @@ -361,8 +367,6 @@ class A2aLocalFacade: self._cleanup_session_devcontainers(session_id) return {"status": "closed"} - if not session_id: - raise ValueError("session_id is required") svc.delete(session_id) # R7-F4 fix: run container cleanup after session deletion.