fix(chat-sessions): safe session deserialization, title guards & error boundary (#23251)

Closed
DI
6d ago
+773-489

Resolves #23251

Description

Hardens chat sessions with safe batch deserialization, title generation guards, and error boundaries:

  1. ChatSessionResponse.deserialize_many_safe:
    • Prevents a single malformed or legacy document in Firestore from crashing GET /v2/chat-sessions.
  2. 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.
  3. Session ID & Title Validation:
    • Guards against whitespace-only session IDs and titles.
  4. Hermetic Unit Tests:
    • Added backend/tests/unit/test_chat_sessions_guards.py (8 tests, 100% pass).

Bounty Details

Connected Issue: #23251
Proposed bounty: $50 USDC
Payout address: 0xC345C07229307d4f1c7935aD2cAe48e390215808 (USDC Polygon/Base/Arbitrum)