Workspace Upload Conversation Fix
Version Implemented: 0.229.001
Issue Description
When uploading files to personal workspaces, the system was incorrectly:
- Creating conversations for each uploaded file
- Displaying files as if they were uploaded to a conversation
- Generating search index errors due to missing
shared_group_idsfield
Root Cause Analysis
Problem 1: Conversation Creation
The personal workspace upload endpoint (/api/documents/upload) in route_backend_documents.py contained code that automatically created conversations and chat messages for every uploaded file. This behavior is inappropriate for workspace uploads, which are meant for document storage and management, not immediate chat interaction.
Problem 2: Search Index Field Error
The update_chunk_metadata function in functions_documents.py was attempting to update the shared_group_ids field in the search index for all workspace types. However, this field doesn't exist in the search index schema for the API version 2024-07-01 being used, causing update failures.
Solution Implemented
Fix 1: Remove Conversation Creation from Personal Workspace Uploads
File: route_backend_documents.py
Change: Removed the entire conversation creation block (lines ~200-280) and replaced it with a simple comment explaining that workspace uploads should not create conversations.
Before:
# Insert a chat message with a content preview for each successfully processed file
for doc in processed_docs:
# ... extensive conversation and message creation code ...
After:
# NOTE: For workspace uploads, we do NOT create conversations or chat messages.
# Files uploaded to workspaces are for document storage/management, not for immediate chat interaction.
# Users can later search these documents in chat if needed.
Fix 2: Conditional Search Index Field Updates
File: functions_documents.py
Changes:
- Modified
update_chunk_metadatato conditionally includeshared_group_idsonly for group workspaces - Updated the calling code to only pass
shared_group_idsfor group workspaces
Before:
updatable_fields = [
'chunk_keywords',
'chunk_summary',
'author',
'title',
'document_classification',
'shared_user_ids',
'shared_group_ids' # This field doesn't exist in personal workspace search index
]
After:
updatable_fields = [
'chunk_keywords',
'chunk_summary',
'author',
'title',
'document_classification',
'shared_user_ids'
]
# Only include shared_group_ids for group workspaces where it exists in the schema
if is_group:
updatable_fields.append('shared_group_ids')
Impact
Fixed Issues
✅ No More Unwanted Conversations: Personal workspace uploads no longer create conversations
✅ No More Search Index Errors: The shared_group_ids field is only updated for group workspaces where it exists
✅ Proper Workspace Behavior: Files uploaded to workspaces are properly stored for document management
✅ Maintained Functionality: Group and public workspace uploads continue to work correctly
User Experience Improvements
- Workspace uploads are faster (no conversation creation overhead)
- No more "File content not found" errors in conversations
- Cleaner conversation list (no auto-generated conversations from workspace uploads)
- Proper separation between workspace document management and chat functionality
Testing
Created comprehensive functional test: test_workspace_upload_conversation_fix.py
Test Coverage:
- ✅ Personal workspace uploads don't create conversations
- ✅ Search index updates filter fields correctly by workspace type
- ✅ Group workspace uploads remain unaffected
- ✅ Public workspace uploads remain unaffected
Files Modified
route_backend_documents.py- Removed conversation creation from personal workspace uploadsfunctions_documents.py- Added conditional field filtering for search index updatesconfig.py- Updated version from0.226.095to0.226.096functional_tests/test_workspace_upload_conversation_fix.py- New test file
Version
Updated from: 0.226.095
Updated to: 0.226.096
Validation
Run the functional test to verify the fix:
python functional_tests/test_workspace_upload_conversation_fix.py
Expected output: All 4 tests should pass, confirming that workspace uploads no longer create conversations and search index updates work correctly.