fix(a2a): validate session_id at entry of _handle_session_close before devcontainer cleanup #11162

Closed
HAL9000 wants to merge 1 commits from pr-fix-11053-session-id-validation into master
2 changed files with 13 additions and 5 deletions
+7 -3
View File
@@ -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)
1
+6 -2
View File
@@ -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.