Skip to content

Bug: /v1/conversations returns 500 — response exceeds Cloud Run 32MB size limit #5424

@beastoin

Description

@beastoin

GET /v1/conversations returns 500 with "Response size was too large" for users with photo-heavy or long conversations. 20 failures in 24h, concentrated on 2 users. Even with limit=50, fully hydrated responses exceed Cloud Run's 32MB response size limit.

Current Behavior

  • The endpoint returns List[Conversation] with full model including all fields
  • @with_photos decorator (database/helpers.py:199-256) loads ALL photos with full base64 content for EACH conversation in the list — 50 separate Firestore sub-collection reads
  • @prepare_for_read adds copy.deepcopy overhead
  • Estimated response size: 50 conversations × ~1.2MB each = ~60MB (1.9x over the 32MB limit)
  • Cloud Run returns "Response size was too large" → 500

Expected Behavior

List endpoint should return lightweight conversation objects. Full details (photos, full transcripts) should be loaded on demand per conversation.

Affected Areas

File Line Description
backend/routers/conversations.py 119 Returns full List[Conversation] with no field filtering
backend/database/conversations.py 177-178 @with_photos + @prepare_for_read decorators on get_conversations()
backend/database/helpers.py 199-256 @with_photos loads all photos with full base64 per conversation
backend/database/conversations.py 141-147 get_conversation_photos() streams full photo docs
backend/models/conversation.py 66-72, 290-328 ConversationPhoto includes base64, full Conversation model

Size Breakdown

Component Per Conversation 50 Conversations
Metadata 2-5 KB 100-250 KB
Transcript segments ~95 KB ~4.7 MB
Photos (base64) ~1 MB (10 photos) ~50 MB
Other fields ~40 KB ~2 MB
Total ~1.2 MB ~57 MB

Solution

Recommended: Create a ConversationLite response model for list endpoints that excludes:

  • Photos base64 content (keep photo IDs/metadata only)
  • Full transcript segment text (keep segment count/duration only)
  • Large plugins_results content

Note: test commits for get_conversations_lite() exist (be1489a23, c391d21d8, a80fbdebf) but the function is not in the current codebase — appears incomplete or reverted.

Files to Modify

  • backend/models/conversation.py — add ConversationLite model
  • backend/routers/conversations.py — use lite model for list endpoint
  • backend/database/conversations.py — add get_conversations_lite() without @with_photos

Impact

Users with many photo-heavy conversations are locked out of their conversation list. Workaround: reduce limit parameter to 10-15.

Related


by AI for @beastoin

Metadata

Metadata

Assignees

No one assigned

    Labels

    backendBackend Task (python)bugSomething isn't workingp2Priority: Important (score 14-21)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions