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: serply credential check query might return empty records (#12784)

rayshaw0015ff08e241a90
diff --git a/api/core/tools/provider/builtin/websearch/tools/job_search.py b/api/core/tools/provider/builtin/websearch/tools/job_search.py
index 293f4f63297..13eb4033915 100644
--- a/api/core/tools/provider/builtin/websearch/tools/job_search.py
+++ b/api/core/tools/provider/builtin/websearch/tools/job_search.py
@@ -43,7 +43,7 @@ class SerplyApi:
def parse_results(res: dict) -> str:
"""Process response from Serply Job Search."""
jobs = res.get("jobs", [])
- if not jobs:
+ if not res or "jobs" not in res:
raise ValueError(f"Got error from Serply: {res}")
string = []
diff --git a/api/core/tools/provider/builtin/websearch/tools/news_search.py b/api/core/tools/provider/builtin/websearch/tools/news_search.py
index 9b5482fe183..7a8a732ff3f 100644
--- a/api/core/tools/provider/builtin/websearch/tools/news_search.py
+++ b/api/core/tools/provider/builtin/websearch/tools/news_search.py
@@ -43,7 +43,7 @@ class SerplyApi:
def parse_results(res: dict) -> str:
"""Process response from Serply News Search."""
news = res.get("entries", [])
- if not news:
+ if not res or "entries" not in res:
raise ValueError(f"Got error from Serply: {res}")
string = []
diff --git a/api/core/tools/provider/builtin/websearch/tools/scholar_search.py b/api/core/tools/provider/builtin/websearch/tools/scholar_search.py
index 798d059b512..32c5d39e5b8 100644
--- a/api/core/tools/provider/builtin/websearch/tools/scholar_search.py
+++ b/api/core/tools/provider/builtin/websearch/tools/scholar_search.py
@@ -43,7 +43,7 @@ class SerplyApi:
def parse_results(res: dict) -> str:
"""Process response from Serply News Search."""
articles = res.get("articles", [])
- if not articles:
+ if not res or "articles" not in res:
raise ValueError(f"Got error from Serply: {res}")
string = []
diff --git a/api/core/tools/provider/builtin/websearch/tools/web_search.py b/api/core/tools/provider/builtin/websearch/tools/web_search.py
index fe363ac7a4d..d0e93cb0fa5 100644
--- a/api/core/tools/provider/builtin/websearch/tools/web_search.py
+++ b/api/core/tools/provider/builtin/websearch/tools/web_search.py
@@ -42,7 +42,7 @@ class SerplyApi:
def parse_results(res: dict) -> str:
"""Process response from Serply Web Search."""
results = res.get("results", [])
- if not results:
+ if not res or "results" not in res:
raise ValueError(f"Got error from Serply: {res}")
string = []