Skip to content

Commit 09436d6

Browse files
committed
fix: Log+ignore invalid chat IDs instead of error
Our example notebook currently uses '12345' (which is not a valid UUID), causing the previous UUID parsing logic to raise HTTP 500. This change keeps the logic, but logs an error and ignores any received invalid conversation IDs. Seems not worth fixing the notebook until we tackle broader deployment question (Terraform for AgentCore)
1 parent 3a34d65 commit 09436d6

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

cx-agent-backend/cx_agent_backend/server.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import time
55
import logging
66
import sys
7+
from uuid import UUID
78

89
from fastapi import FastAPI, HTTPException, Request
910
import structlog
@@ -69,8 +70,14 @@ async def invocations(request: dict, http_request: Request):
6970
langfuse_tags = input_data.get("langfuse_tags", [])
7071

7172
# Convert conversation_id to UUID
72-
from uuid import UUID
73-
conversation_id = UUID(conversation_id_str) if conversation_id_str else None
73+
try:
74+
conversation_id = UUID(conversation_id_str) if conversation_id_str else None
75+
except:
76+
logger.exception(
77+
"Failed to parse provided Conversation ID '%s' to valid UUID - Treating as empty",
78+
conversation_id_str
79+
)
80+
conversation_id = None
7481

7582
if not prompt and not feedback:
7683
raise HTTPException(status_code=400, detail="Either prompt or feedback must be provided in input.")

0 commit comments

Comments
 (0)