From 069f49fcd2676d7a150554b0036239fe1c0762e1 Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Sun, 23 Aug 2026 18:59:05 +0200 Subject: [PATCH] refac: remove unreachable rate limit handler from DuckDuckGo web search (#28943) The DuckDuckGo search path catches RatelimitException from the ddgs library. That exception is defined by the library but never raised anywhere in it, checked against the pinned 9.14.4 and against 9.11.3, so the handler could never run. The two fallbacks around it were dead for the same reason: ddgs.text() returns a non-empty list or raises, so None and an empty list are not outcomes it can produce. Removing all three leaves one call and changes nothing observable. A refused or rate limited search already came out as a failed search, with the error shown to the user and the traceback in the log, and it still does. The backend argument is now passed as backend or 'auto' rather than conditionally omitted, because 'auto' is the library's own default for that parameter, so every configured value including unset and empty resolves exactly as before. Verified by running the old and the new function side by side against a stubbed library covering normal results, the domain filter, all four backend settings and a failing search, with identical results in every case. --- backend/open_webui/retrieval/web/duckduckgo.py | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/backend/open_webui/retrieval/web/duckduckgo.py b/backend/open_webui/retrieval/web/duckduckgo.py index 27d56f6934..2d57b071cd 100644 --- a/backend/open_webui/retrieval/web/duckduckgo.py +++ b/backend/open_webui/retrieval/web/duckduckgo.py @@ -4,7 +4,6 @@ import logging import urllib.request from ddgs import DDGS -from ddgs.exceptions import RatelimitException from open_webui.retrieval.web.main import SearchResult, get_filtered_results log = logging.getLogger(__name__) @@ -31,21 +30,11 @@ def search_duckduckgo( # Resolve via stdlib getproxies() — same pattern as the other loaders. env_proxies = urllib.request.getproxies() proxy = env_proxies.get('https') or env_proxies.get('http') - search_results = [] with DDGS(proxy=proxy) as ddgs: if concurrent_requests: ddgs.threads = concurrent_requests - # Use the ddgs.text() method to perform the search - try: - kwargs = {'safesearch': 'moderate', 'max_results': count} - if backend and backend != 'auto': - kwargs['backend'] = backend - results = ddgs.text(query, **kwargs) - search_results = results if results is not None else [] - except RatelimitException as e: - log.error(f'RatelimitException: {e}') - search_results = [] + search_results = ddgs.text(query, safesearch='moderate', max_results=count, backend=backend or 'auto') if filter_list: search_results = get_filtered_results(search_results, filter_list)