fix: raise ValueError when sessionId and userId are incorrect combination(#1653)

Merge https://github.com/google/adk-python/pull/1655

Fix #1653

When session_id and user_id are incorrect combination on vertex ai session service, it should not return the session.

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/1655 from soundTricker:fix/1653-invalid-session 7a3dee2fc75602a2685ea922799cc5f5ba666e97
PiperOrigin-RevId: 776648361
This commit is contained in:
Keisuke Oohashi
2025-06-27 11:06:15 -07:00
committed by Copybara-Service
parent c13c9875cf
commit 4e765ae2f3
2 changed files with 18 additions and 0 deletions
@@ -178,6 +178,9 @@ class VertexAiSessionService(BaseSessionService):
)
get_session_api_response = _convert_api_response(get_session_api_response)
if get_session_api_response['userId'] != user_id:
raise ValueError(f'Session not found: {session_id}')
session_id = get_session_api_response['name'].split('/')[-1]
update_timestamp = isoparse(
get_session_api_response['updateTime']