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: improved error handling for spider tool (#6835)

William Espegren4be12b29b98e
diff --git a/api/core/tools/provider/builtin/spider/spider.py b/api/core/tools/provider/builtin/spider/spider.py
index 6fa431b6bb6..5bcc56a7248 100644
--- a/api/core/tools/provider/builtin/spider/spider.py
+++ b/api/core/tools/provider/builtin/spider/spider.py
@@ -8,7 +8,13 @@ from core.tools.provider.builtin_tool_provider import BuiltinToolProviderControl
class SpiderProvider(BuiltinToolProviderController):
def _validate_credentials(self, credentials: dict[str, Any]) -> None:
try:
- app = Spider(api_key=credentials["spider_api_key"])
- app.scrape_url(url="https://spider.cloud")
+ app = Spider(api_key=credentials['spider_api_key'])
+ app.scrape_url(url='https://spider.cloud')
+ except AttributeError as e:
+ # Handle cases where NoneType is not iterable, which might indicate API issues
+ if 'NoneType' in str(e) and 'not iterable' in str(e):
+ raise ToolProviderCredentialValidationError('API is currently down, try again in 15 minutes', str(e))
+ else:
+ raise ToolProviderCredentialValidationError('An unexpected error occurred.', str(e))
except Exception as e:
- raise ToolProviderCredentialValidationError(str(e))
+ raise ToolProviderCredentialValidationError('An unexpected error occurred.', str(e))