Fix:validate knowledge base association before document upload (#5373)

### What problem does this PR solve?

fix this bug: https://github.com/infiniflow/ragflow/issues/5368

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)

Co-authored-by: wenju.li <wenju.li@deepctr.cn>
This commit is contained in:
liwenju0 2025-02-26 15:47:34 +08:00 committed by GitHub
parent 4f40f685d9
commit a9e4695b74
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -504,6 +504,9 @@ def doc_upload_and_parse(conversation_id, file_objs, user_id):
assert e, "Conversation not found!" assert e, "Conversation not found!"
e, dia = DialogService.get_by_id(conv.dialog_id) e, dia = DialogService.get_by_id(conv.dialog_id)
if not dia.kb_ids:
raise LookupError("No knowledge base associated with this conversation. "
"Please add a knowledge base before uploading documents")
kb_id = dia.kb_ids[0] kb_id = dia.kb_ids[0]
e, kb = KnowledgebaseService.get_by_id(kb_id) e, kb = KnowledgebaseService.get_by_id(kb_id)
if not e: if not e: