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: resolve 500 error when updating document chunk settings (#27551) (#27574)

quicksandaddebc465a90
diff --git a/api/services/dataset_service.py b/api/services/dataset_service.py
index 1e040abe3e0..a3e62544c64 100644
--- a/api/services/dataset_service.py
+++ b/api/services/dataset_service.py
@@ -1416,8 +1416,6 @@ class DocumentService:
# check document limit
assert isinstance(current_user, Account)
assert current_user.current_tenant_id is not None
- assert knowledge_config.data_source
- assert knowledge_config.data_source.info_list
features = FeatureService.get_features(current_user.current_tenant_id)
@@ -1448,7 +1446,7 @@ class DocumentService:
DocumentService.check_documents_upload_quota(count, features)
# if dataset is empty, update dataset data_source_type
- if not dataset.data_source_type:
+ if not dataset.data_source_type and knowledge_config.data_source:
dataset.data_source_type = knowledge_config.data_source.info_list.data_source_type
if not dataset.indexing_technique:
@@ -1494,6 +1492,10 @@ class DocumentService:
documents.append(document)
batch = document.batch
else:
+ # When creating new documents, data_source must be provided
+ if not knowledge_config.data_source:
+ raise ValueError("Data source is required when creating new documents")
+
batch = time.strftime("%Y%m%d%H%M%S") + str(100000 + secrets.randbelow(exclusive_upper_bound=900000))
# save process rule
if not dataset_process_rule: