fix(chat-sessions): safe session deserialization, title guards & error boundary (#23251)
Closed
DI
6d ago+773+773+012345678901234567890123456789-489-489-012345678901234567890123456789
Resolves #23251
Description
Hardens chat sessions with safe batch deserialization, title generation guards, and error boundaries:
ChatSessionResponse.deserialize_many_safe:- Prevents a single malformed or legacy document in Firestore from crashing
GET /v2/chat-sessions.
- Prevents a single malformed or legacy document in Firestore from crashing
- Structured LLM Unpacking & Error Boundary in
generate_session_title:- Safely parses string content across
str,list[dict], and objects. - Catches transient LLM exceptions and falls back cleanly to a message excerpt or 'New Chat'.
- Validates session existence returning 404.
- Safely parses string content across
- Session ID & Title Validation:
- Guards against whitespace-only session IDs and titles.
- Hermetic Unit Tests:
- Added
backend/tests/unit/test_chat_sessions_guards.py(8 tests, 100% pass).
- Added
Bounty Details
Connected Issue: #23251
Proposed bounty: $50 USDC
Payout address: 0xC345C07229307d4f1c7935aD2cAe48e390215808 (USDC Polygon/Base/Arbitrum)