mirror of
https://github.com/encounter/adk-python.git
synced 2026-07-09 18:19:28 -07:00
chore: Throw 409 already exist error when trying to create a session with existing id
Resolves https://github.com/google/adk-python/issues/2950 PiperOrigin-RevId: 821362008
This commit is contained in:
committed by
Copybara-Service
parent
a5b742b360
commit
d327538724
@@ -741,7 +741,7 @@ class AdkWebServer:
|
||||
is not None
|
||||
):
|
||||
raise HTTPException(
|
||||
status_code=400, detail=f"Session already exists: {session_id}"
|
||||
status_code=409, detail=f"Session already exists: {session_id}"
|
||||
)
|
||||
session = await self.session_service.create_session(
|
||||
app_name=app_name, user_id=user_id, state=state, session_id=session_id
|
||||
@@ -763,6 +763,13 @@ class AdkWebServer:
|
||||
app_name=app_name, user_id=user_id
|
||||
)
|
||||
|
||||
if req.session_id and await self.session_service.get_session(
|
||||
app_name=app_name, user_id=user_id, session_id=req.session_id
|
||||
):
|
||||
raise HTTPException(
|
||||
status_code=409, detail=f"Session already exists: {req.session_id}"
|
||||
)
|
||||
|
||||
session = await self.session_service.create_session(
|
||||
app_name=app_name,
|
||||
user_id=user_id,
|
||||
|
||||
Reference in New Issue
Block a user