diff --git a/backend/app/api/endpoints/ai_sessions.py b/backend/app/api/endpoints/ai_sessions.py index d245b3bc..7b80b935 100644 --- a/backend/app/api/endpoints/ai_sessions.py +++ b/backend/app/api/endpoints/ai_sessions.py @@ -645,9 +645,16 @@ async def get_session( confidence_score=step.confidence_at_step, )) - detail = AISessionDetail.model_validate(session) - detail.steps = step_responses - return detail + try: + detail = AISessionDetail.model_validate(session) + detail.steps = step_responses + return detail + except Exception as e: + logger.exception("Failed to serialize session %s: %s", session_id, e) + raise HTTPException( + status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, + detail=f"Session serialization error: {type(e).__name__}: {str(e)[:200]}", + ) # ── Documentation ──