RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.
Go agent-harnessagent-native-databaseagentic-aiagentic-retrievalagentic-searchaiai-agentscontext-enginecontext-engineeringcontext-managementharness-engineeringknowledge-compilationragretrieval-augmented-generationretrieval-harnesssearch-harness
fix: metadata_condition returning all docs when filter matches nothing (#14967)
Hamza Amin Khokhar2dbe3b8a6227
diff --git a/api/apps/restful_apis/document_api.py b/api/apps/restful_apis/document_api.pyindex 7547d2f20b..57215080d3 100644--- a/api/apps/restful_apis/document_api.py+++ b/api/apps/restful_apis/document_api.py@@ -995,7 +995,7 @@ def _parse_doc_id_filter_with_metadata(req, kb_id):if not doc_ids_filter:return RetCode.SUCCESS, "", [], return_empty_metadata- return RetCode.SUCCESS, "", list(doc_ids_filter) if doc_ids_filter is not None else [], return_empty_metadata+ return RetCode.SUCCESS, "", list(doc_ids_filter) if doc_ids_filter is not None else None, return_empty_metadata@manager.route("/datasets/<dataset_id>/documents", methods=["DELETE"]) # noqa: F821diff --git a/api/db/services/document_service.py b/api/db/services/document_service.pyindex 3d9bc09dbb..7b0bce6e62 100644--- a/api/db/services/document_service.py+++ b/api/db/services/document_service.py@@ -88,7 +88,7 @@ class DocumentService(CommonService):docs = docs.where(cls.model.name == name)if keywords:docs = docs.where(fn.LOWER(cls.model.name).contains(keywords.lower()))- if doc_ids:+ if doc_ids is not None:docs = docs.where(cls.model.id.in_(doc_ids))if suffix:docs = docs.where(cls.model.suffix.in_(suffix))@@ -143,7 +143,7 @@ class DocumentService(CommonService):.join(User, on=(cls.model.created_by == User.id), join_type=JOIN.LEFT_OUTER).where(cls.model.kb_id == kb_id))- if doc_ids:+ if doc_ids is not None:docs = docs.where(cls.model.id.in_(doc_ids))if run_status:docs = docs.where(cls.model.run.in_(run_status))