Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix delete dataset when dataset has no document (#2789)

Jyong796c5626a743
diff --git a/api/tasks/clean_dataset_task.py b/api/tasks/clean_dataset_task.py
index 37e109c8475..b9737d7dddf 100644
--- a/api/tasks/clean_dataset_task.py
+++ b/api/tasks/clean_dataset_task.py
@@ -44,6 +44,10 @@ def clean_dataset_task(dataset_id: str, tenant_id: str, indexing_technique: str,
documents = db.session.query(Document).filter(Document.dataset_id == dataset_id).all()
segments = db.session.query(DocumentSegment).filter(DocumentSegment.dataset_id == dataset_id).all()
+ if documents is None or len(documents) == 0:
+ logging.info(click.style('No documents found for dataset: {}'.format(dataset_id), fg='green'))
+ return
+
index_processor = IndexProcessorFactory(doc_form).init_index_processor()
index_processor.clean(dataset, None)