This commit is contained in:
Timothy Jaeryang Baek 2026-08-16 23:21:00 -07:00
parent b211c407f4
commit 1a376ac17f
2 changed files with 22 additions and 3 deletions

View file

@ -411,6 +411,11 @@ class EventDefinitions(BaseModel):
description='Retrieval content was processed.',
message='Retrieval Content processed',
)
RETRIEVAL_CONTENT_PROCESS_FAILED: EventDefinition = EventDefinition(
name='retrieval.content.process_failed',
description='Retrieval content processing failed.',
message='Retrieval Content process failed',
)
RETRIEVAL_COLLECTION_DELETED: EventDefinition = EventDefinition(
name='retrieval.collection.deleted',
description='A retrieval collection was deleted.',
@ -666,6 +671,7 @@ NOTIFICATION_EVENTS = (
EVENTS.CHAT_FAILED.name,
EVENTS.CHANNEL_MESSAGE.name,
EVENTS.CALENDAR_ALERT.name,
EVENTS.RETRIEVAL_CONTENT_PROCESS_FAILED.name,
)

View file

@ -1998,7 +1998,7 @@ async def process_file(
hash = calculate_sha256_string(text_content)
if config.BYPASS_EMBEDDING_AND_RETRIEVAL:
await Files.update_file_data_by_id(file.id, {'status': 'completed'}, db=db)
await Files.update_file_data_by_id(file.id, {'status': 'completed', 'error': None}, db=db)
await Files.update_file_hash_by_id(file.id, hash, db=db)
await publish_event(
request,
@ -2057,7 +2057,7 @@ async def process_file(
await Files.update_file_data_by_id(
file.id,
{'status': 'completed'},
{'status': 'completed', 'error': None},
db=session,
)
await Files.update_file_hash_by_id(file.id, hash, db=session)
@ -2087,12 +2087,25 @@ async def process_file(
async with get_async_db() as session:
await Files.update_file_data_by_id(
file.id,
{'status': 'failed'},
{'status': 'failed', 'error': str(e)},
db=session,
)
# Clear the hash so the file can be re-uploaded after fixing the issue
await Files.update_file_hash_by_id(file.id, None, db=session)
await publish_event(
request,
EVENTS.RETRIEVAL_CONTENT_PROCESS_FAILED,
actor=user,
subject_id=file.id,
subject_type='file',
data={
'collection_name': collection_name,
'filename': file.filename,
'message': f'{file.filename}: {e}',
},
)
if 'No pandoc was found' in str(e):
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,