Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

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

liwenju0a9e4695b7418
diff --git a/api/db/services/document_service.py b/api/db/services/document_service.py
index 4e94f92842..4c59271ece 100644
--- a/api/db/services/document_service.py
+++ b/api/db/services/document_service.py
@@ -504,6 +504,9 @@ def doc_upload_and_parse(conversation_id, file_objs, user_id):
assert e, "Conversation not found!"
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]
e, kb = KnowledgebaseService.get_by_id(kb_id)
if not e: