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: better error message for url add external knowledge (#11537)

yihong50b76dd5a2ea
diff --git a/api/services/external_knowledge_service.py b/api/services/external_knowledge_service.py
index 7e3cd87f1ee..7be20301a74 100644
--- a/api/services/external_knowledge_service.py
+++ b/api/services/external_knowledge_service.py
@@ -69,7 +69,10 @@ class ExternalDatasetService:
endpoint = f"{settings['endpoint']}/retrieval"
api_key = settings["api_key"]
if not validators.url(endpoint, simple_host=True):
- raise ValueError(f"invalid endpoint: {endpoint}")
+ if not endpoint.startswith("http://") and not endpoint.startswith("https://"):
+ raise ValueError(f"invalid endpoint: {endpoint} must start with http:// or https://")
+ else:
+ raise ValueError(f"invalid endpoint: {endpoint}")
try:
response = httpx.post(endpoint, headers={"Authorization": f"Bearer {api_key}"})
except Exception as e: