[GH-ISSUE #24560] issue: SafeWebBaseLoader._fetch crashes with TypeError on duplicate allow_redirects kwarg, breaking all web search in v0.9.5 #74937

Open
opened 2026-05-13 07:48:25 -05:00 by GiteaMirror · 6 comments
Owner

Originally created by @blaknite on GitHub (May 11, 2026).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/24560

Check Existing Issues

  • I have searched for any existing and/or related issues.
  • I have searched for any existing and/or related discussions.
  • I have also searched in the CLOSED issues AND CLOSED discussions and found no related items.
  • I am using the latest version of Open WebUI.

Installation Method

Other (uvx open-webui@latest serve under systemd)

Open WebUI Version

v0.9.5

Ollama Version (if applicable)

N/A

Operating System

Ubuntu 22.04 LTS

Browser (if applicable)

N/A — failure is server-side.

Confirmation

  • I have read and followed all instructions in README.md.
  • I am using the latest version of both Open WebUI and Ollama.
  • I have included the browser console logs.
  • I have included the Docker container logs.
  • I have provided every relevant configuration, setting, and environment variable used in my setup.
  • I have clearly listed every relevant configuration, custom setting, environment variable, and command-line option that influences my setup.
  • I have documented step-by-step reproduction instructions.

Expected Behavior

With web search enabled and WEB_LOADER_ENGINE at its default (safe_web), the loader fetches the URLs returned by the search engine and feeds their content into the LLM context.

Actual Behavior

Every URL fails to fetch. The failure is swallowed because continue_on_failure=True, so all you see in the logs is:

```
WARNING | langchain_community.document_loaders.web_base:_fetch_with_rate_limit:271 - Error fetching , skipping due to continue_on_failure=True
```

After patching langchain to surface the swallowed exception, every fetch raises:

```
TypeError: aiohttp.client.ClientSession.get() got multiple values for keyword argument 'allow_redirects'
```

Root cause

In backend/open_webui/retrieval/web/utils.py, SafeWebBaseLoader.__init__ puts allow_redirects into self.requests_kwargs:

```python
self.requests_kwargs = {
**(self.requests_kwargs or {}),
'allow_redirects': AIOHTTP_CLIENT_ALLOW_REDIRECTS,
}
```

Then _fetch unpacks self.requests_kwargs into session.get(...) and also passes allow_redirects explicitly:

```python
async with session.get(
url,
**(self.requests_kwargs | kwargs),
allow_redirects=AIOHTTP_CLIENT_ALLOW_REDIRECTS,
) as response:
```

aiohttp rejects the duplicate kwarg on every call. The bug is on main as well as the v0.9.5 tag, and was introduced by PR #24524.

Fix

Drop the explicit allow_redirects=AIOHTTP_CLIENT_ALLOW_REDIRECTS, line from the session.get(...) call. The value is already in self.requests_kwargs, so the SSRF protection is preserved.

Steps to Reproduce

  1. Install Open WebUI v0.9.5.
  2. Open Admin Panel > Settings > Web Search.
  3. Toggle "Enable Web Search" on, pick any provider (reproduced with DuckDuckGo).
  4. Leave "Web Loader Engine" on its default (the empty/safe_web option).
  5. Leave "Bypass Web Loader" off.
  6. Save.
  7. Start a chat, toggle web search on for the message, submit any prompt that triggers a search.

Expected: search runs, URLs are fetched, content reaches the model.
Actual: search finds URLs, every fetch fails silently, the model gets no web context.

Logs & Screenshots

After patching langchain_community/document_loaders/web_base.py:_fetch_with_rate_limit to log the swallowed exception:

```
2026-05-11 02:27:28.466 | ERROR | langchain_community.document_loaders.web_base:_fetch_with_rate_limit:271 - Error fetching https://openrouter.ai/qwen/qwen3.5-35b-a3b [TypeError: aiohttp.client.ClientSession.get() got multiple values for keyword argument 'allow_redirects'], skipping due to continue_on_failure=True
Traceback (most recent call last):
File ".../open_webui/retrieval/web/utils.py", line 521, in _fetch
async with session.get(
url,
**(self.requests_kwargs | kwargs),
allow_redirects=AIOHTTP_CLIENT_ALLOW_REDIRECTS,
) as response:
TypeError: aiohttp.client.ClientSession.get() got multiple values for keyword argument 'allow_redirects'
```

Additional Information

Workarounds:

  • Turn on "Bypass Web Loader" in Web Search settings to use search-engine snippets only (loses page content).
  • Switch "Web Loader Engine" to Tavily, Firecrawl, or External — they bypass SafeWebBaseLoader._fetch.
  • Patch SafeWebBaseLoader._fetch locally to remove the duplicate allow_redirects kwarg.

Thanks for all your work on Open WebUI.

Originally created by @blaknite on GitHub (May 11, 2026). Original GitHub issue: https://github.com/open-webui/open-webui/issues/24560 ### Check Existing Issues - [x] I have searched for any existing and/or related issues. - [x] I have searched for any existing and/or related discussions. - [x] I have also searched in the CLOSED issues AND CLOSED discussions and found no related items. - [x] I am using the latest version of Open WebUI. ### Installation Method Other (`uvx open-webui@latest serve` under systemd) ### Open WebUI Version v0.9.5 ### Ollama Version (if applicable) N/A ### Operating System Ubuntu 22.04 LTS ### Browser (if applicable) N/A — failure is server-side. ### Confirmation - [x] I have read and followed all instructions in `README.md`. - [x] I am using the latest version of **both** Open WebUI and Ollama. - [x] I have included the browser console logs. - [x] I have included the Docker container logs. - [x] I have provided every relevant configuration, setting, and environment variable used in my setup. - [x] I have clearly listed every relevant configuration, custom setting, environment variable, and command-line option that influences my setup. - [x] I have documented step-by-step reproduction instructions. ### Expected Behavior With web search enabled and `WEB_LOADER_ENGINE` at its default (`safe_web`), the loader fetches the URLs returned by the search engine and feeds their content into the LLM context. ### Actual Behavior Every URL fails to fetch. The failure is swallowed because `continue_on_failure=True`, so all you see in the logs is: \`\`\` WARNING | langchain_community.document_loaders.web_base:_fetch_with_rate_limit:271 - Error fetching <url>, skipping due to continue_on_failure=True \`\`\` After patching langchain to surface the swallowed exception, every fetch raises: \`\`\` TypeError: aiohttp.client.ClientSession.get() got multiple values for keyword argument 'allow_redirects' \`\`\` ### Root cause In `backend/open_webui/retrieval/web/utils.py`, `SafeWebBaseLoader.__init__` puts `allow_redirects` into `self.requests_kwargs`: \`\`\`python self.requests_kwargs = { **(self.requests_kwargs or {}), 'allow_redirects': AIOHTTP_CLIENT_ALLOW_REDIRECTS, } \`\`\` Then `_fetch` unpacks `self.requests_kwargs` into `session.get(...)` and also passes `allow_redirects` explicitly: \`\`\`python async with session.get( url, **(self.requests_kwargs | kwargs), allow_redirects=AIOHTTP_CLIENT_ALLOW_REDIRECTS, ) as response: \`\`\` `aiohttp` rejects the duplicate kwarg on every call. The bug is on `main` as well as the v0.9.5 tag, and was introduced by PR #24524. ### Fix Drop the explicit `allow_redirects=AIOHTTP_CLIENT_ALLOW_REDIRECTS,` line from the `session.get(...)` call. The value is already in `self.requests_kwargs`, so the SSRF protection is preserved. ### Steps to Reproduce 1. Install Open WebUI v0.9.5. 2. Open Admin Panel > Settings > Web Search. 3. Toggle "Enable Web Search" on, pick any provider (reproduced with DuckDuckGo). 4. Leave "Web Loader Engine" on its default (the empty/`safe_web` option). 5. Leave "Bypass Web Loader" off. 6. Save. 7. Start a chat, toggle web search on for the message, submit any prompt that triggers a search. Expected: search runs, URLs are fetched, content reaches the model. Actual: search finds URLs, every fetch fails silently, the model gets no web context. ### Logs & Screenshots After patching `langchain_community/document_loaders/web_base.py:_fetch_with_rate_limit` to log the swallowed exception: \`\`\` 2026-05-11 02:27:28.466 | ERROR | langchain_community.document_loaders.web_base:_fetch_with_rate_limit:271 - Error fetching https://openrouter.ai/qwen/qwen3.5-35b-a3b [TypeError: aiohttp.client.ClientSession.get() got multiple values for keyword argument 'allow_redirects'], skipping due to continue_on_failure=True Traceback (most recent call last): File ".../open_webui/retrieval/web/utils.py", line 521, in _fetch async with session.get( url, **(self.requests_kwargs | kwargs), allow_redirects=AIOHTTP_CLIENT_ALLOW_REDIRECTS, ) as response: TypeError: aiohttp.client.ClientSession.get() got multiple values for keyword argument 'allow_redirects' \`\`\` ### Additional Information Workarounds: - Turn on "Bypass Web Loader" in Web Search settings to use search-engine snippets only (loses page content). - Switch "Web Loader Engine" to Tavily, Firecrawl, or External — they bypass `SafeWebBaseLoader._fetch`. - Patch `SafeWebBaseLoader._fetch` locally to remove the duplicate `allow_redirects` kwarg. Thanks for all your work on Open WebUI.
Author
Owner

@owui-terminator[bot] commented on GitHub (May 11, 2026):

🔍 Related Issues Found

I found some existing issues that might be related. Please check if any of these are duplicates or contain helpful solutions:

  1. 🟣 #24017 issue: Web search breaks persistently after setting Fetch URL Content Length Limit to 80000
    This is another web-search regression in the same retrieval/web search pipeline, affecting fetch behavior after a configuration change. While the trigger differs, it is the closest existing report in the web search loader area.
    by mero20j1 · bug

  2. 🟣 #18686 issue: calling the /api/v1/retireval/process/web/search causes entire website to hang
    This issue reports the web search endpoint hanging because the web loading path blocks the main thread. It is related to the same web retrieval flow, though the failure mode is different from the duplicate kwarg crash.
    by OAburub · bug

  3. 🟣 #15498 issue: "Bypass Web Loader" toggle gives error with Brave web search
    This is a prior web-search/bypass-loader bug in the web retrieval subsystem. It involves the same web loader path and is useful as a related historical issue, even though the specific error is different.
    by teese · bug


💡 If your issue is a duplicate, please close it and add any additional details to the existing issue instead.

This comment was generated automatically. React with 👍 if helpful, 👎 if not.

<!-- gh-comment-id:4417197541 --> @owui-terminator[bot] commented on GitHub (May 11, 2026): <!-- terminator-bot:related-issues-reply --> 🔍 **Related Issues Found** I found some existing issues that might be related. Please check if any of these are duplicates or contain helpful solutions: 1. 🟣 [#24017](https://github.com/open-webui/open-webui/issues/24017) **issue: Web search breaks persistently after setting Fetch URL Content Length Limit to 80000** *This is another web-search regression in the same retrieval/web search pipeline, affecting fetch behavior after a configuration change. While the trigger differs, it is the closest existing report in the web search loader area.* *by mero20j1 · `bug`* 2. 🟣 [#18686](https://github.com/open-webui/open-webui/issues/18686) **issue: calling the /api/v1/retireval/process/web/search causes entire website to hang** *This issue reports the web search endpoint hanging because the web loading path blocks the main thread. It is related to the same web retrieval flow, though the failure mode is different from the duplicate kwarg crash.* *by OAburub · `bug`* 3. 🟣 [#15498](https://github.com/open-webui/open-webui/issues/15498) **issue: "Bypass Web Loader" toggle gives error with Brave web search** *This is a prior web-search/bypass-loader bug in the web retrieval subsystem. It involves the same web loader path and is useful as a related historical issue, even though the specific error is different.* *by teese · `bug`* --- 💡 If your issue is a duplicate, please close it and add any additional details to the existing issue instead. *This comment was generated automatically.* React with 👍 if helpful, 👎 if not.
Author
Owner

@farid-abu-issa commented on GitHub (May 11, 2026):

Confirming on Railway deployment, Tavily engine. v0.9.2 → v0.9.5
upgrade broke web search the moment Bypass Web Loader was OFF.
AIOHTTP_CLIENT_ALLOW_REDIRECTS=true did not help (consistent with
the duplicate kwarg diagnosis). Rolled back to v0.9.2, working again.

<!-- gh-comment-id:4417356390 --> @farid-abu-issa commented on GitHub (May 11, 2026): Confirming on Railway deployment, Tavily engine. v0.9.2 → v0.9.5 upgrade broke web search the moment Bypass Web Loader was OFF. AIOHTTP_CLIENT_ALLOW_REDIRECTS=true did not help (consistent with the duplicate kwarg diagnosis). Rolled back to v0.9.2, working again.
Author
Owner

@bootcnode commented on GitHub (May 12, 2026):

Thank you for reporting this, I couldn't figure out why all my web-searches was broken. Rolling back to 0.9.2 has solved the issue for me.

<!-- gh-comment-id:4428654271 --> @bootcnode commented on GitHub (May 12, 2026): Thank you for reporting this, I couldn't figure out why all my web-searches was broken. Rolling back to 0.9.2 has solved the issue for me.
Author
Owner

@tezgno commented on GitHub (May 12, 2026):

I can also confirm this behavior and was diving into it when I saw this post. I rolled back to 0.9.2 and the issue is resolved as well.

<!-- gh-comment-id:4433409864 --> @tezgno commented on GitHub (May 12, 2026): I can also confirm this behavior and was diving into it when I saw this post. I rolled back to 0.9.2 and the issue is resolved as well.
Author
Owner

@da-astro commented on GitHub (May 12, 2026):

Confirmed on :dev as of 2026-05-12

I can confirm this bug still reproduces on ghcr.io/open-webui/open-webui:dev (pulled fresh today). Same traceback:

TypeError: aiohttp.client.ClientSession.get() got multiple values for keyword argument 'allow_redirects'
  File "/app/backend/open_webui/retrieval/web/utils.py", line 529, in _fetch
    async with session.get(

Applying the fix locally (popping allow_redirects from the merged dict before the call) resolves the TypeError and web search begins fetching content successfully.


Secondary Issue: USER_AGENT not propagated

After fixing the allow_redirects bug, a second issue surfaces: get_web_loader() does not propagate the USER_AGENT environment variable to SafeWebBaseLoader.

The session defaults to python-requests/2.x as the User-Agent, which many sites (Cloudflare-protected pages, anti-bot systems, rate-limiters like Wikipedia) block or throttle aggressively. This causes fetches to either fail outright (403/Cloudflare block pages) or return empty/error content even though the loader is working correctly.

Fix

Add this in SafeWebBaseLoader.__init__() after super().__init__():

# Propagate USER_AGENT env to session headers for both sync and async paths
import os as _os
_ua = _os.environ.get('USER_AGENT') or 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36'
self.session.headers['User-Agent'] = _ua

This ensures the session sends a real browser UA on both the synchronous (load()) and asynchronous (aload()_fetch()) paths. The _fetch() method already propagates self.session.headers to the aiohttp session (line ~513: headers=self.session.headers), so setting it once in __init__ covers both.

Validation

After applying both fixes (allow_redirects + USER_AGENT), web search fetches work end-to-end:

curl -s -X POST https://.../api/chat/completions \
  -H "Content-Type: application/json" \
  -d '{"model":"llama32--web-search","messages":[{"role":"user","content":"latest SpaceX news"}],"stream":false,"features":{"web_search":true}}' \
  | jq '.sources[0].source.docs | map({url: .metadata.source, chars: (.content | length)})'

Before fixes: every entry shows chars: 0
After fixes: most entries show thousands of chars (some still fail due to paywalls/Cloudflare, which is expected)

Example output post-fix:

14,418 chars | https://www.space.com/space-exploration/launches-spacecraft/spacex-falcon-9-rocket-launch-nrol-172-spy-satellite-mission
23,251 chars | https://www.rocketlaunch.live/?filter=spacex
   141 chars | https://en.wikipedia.org/wiki/... (Wikipedia bot rate limit — expected)
    34 chars | https://www.spacex.com/launches (Cloudflare block — expected)

Recommendation: Address both issues together so web search works out-of-the-box without requiring users to set USER_AGENT manually or patch the loader.

<!-- gh-comment-id:4433989205 --> @da-astro commented on GitHub (May 12, 2026): ## Confirmed on `:dev` as of 2026-05-12 I can confirm this bug still reproduces on `ghcr.io/open-webui/open-webui:dev` (pulled fresh today). Same traceback: ``` TypeError: aiohttp.client.ClientSession.get() got multiple values for keyword argument 'allow_redirects' File "/app/backend/open_webui/retrieval/web/utils.py", line 529, in _fetch async with session.get( ``` Applying the fix locally (popping `allow_redirects` from the merged dict before the call) resolves the TypeError and web search begins fetching content successfully. --- ## Secondary Issue: USER_AGENT not propagated **After** fixing the `allow_redirects` bug, a second issue surfaces: `get_web_loader()` does not propagate the `USER_AGENT` environment variable to `SafeWebBaseLoader`. The session defaults to `python-requests/2.x` as the User-Agent, which many sites (Cloudflare-protected pages, anti-bot systems, rate-limiters like Wikipedia) block or throttle aggressively. This causes fetches to either fail outright (403/Cloudflare block pages) or return empty/error content even though the loader is working correctly. ### Fix Add this in `SafeWebBaseLoader.__init__()` after `super().__init__()`: ```python # Propagate USER_AGENT env to session headers for both sync and async paths import os as _os _ua = _os.environ.get('USER_AGENT') or 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36' self.session.headers['User-Agent'] = _ua ``` This ensures the session sends a real browser UA on both the synchronous (`load()`) and asynchronous (`aload()` → `_fetch()`) paths. The `_fetch()` method already propagates `self.session.headers` to the aiohttp session (line ~513: `headers=self.session.headers`), so setting it once in `__init__` covers both. ### Validation After applying both fixes (allow_redirects + USER_AGENT), web search fetches work end-to-end: ```bash curl -s -X POST https://.../api/chat/completions \ -H "Content-Type: application/json" \ -d '{"model":"llama32--web-search","messages":[{"role":"user","content":"latest SpaceX news"}],"stream":false,"features":{"web_search":true}}' \ | jq '.sources[0].source.docs | map({url: .metadata.source, chars: (.content | length)})' ``` **Before fixes:** every entry shows `chars: 0` **After fixes:** most entries show thousands of chars (some still fail due to paywalls/Cloudflare, which is expected) Example output post-fix: ``` 14,418 chars | https://www.space.com/space-exploration/launches-spacecraft/spacex-falcon-9-rocket-launch-nrol-172-spy-satellite-mission 23,251 chars | https://www.rocketlaunch.live/?filter=spacex 141 chars | https://en.wikipedia.org/wiki/... (Wikipedia bot rate limit — expected) 34 chars | https://www.spacex.com/launches (Cloudflare block — expected) ``` --- **Recommendation:** Address both issues together so web search works out-of-the-box without requiring users to set `USER_AGENT` manually or patch the loader.
Author
Owner

@farid-abu-issa commented on GitHub (May 12, 2026):

Adding a +1 on @da-astro's USER_AGENT finding. Worth flagging this
clearly so it isn't missed in the v0.9.6 review cycle.

The allow_redirects fix (PR #24602) addresses the immediate TypeError,
but if shipped alone, real-world web search will still degrade on
Cloudflare-protected sites, Wikipedia, and any host with bot
detection — exactly the sites users hit most often. The
python-requests UA gets blocked or rate-limited aggressively.

Would strongly recommend merging both fixes together in v0.9.6 so
users don't roll forward, find search "technically working" but
empty on half the sites, and roll back again.

<!-- gh-comment-id:4434621169 --> @farid-abu-issa commented on GitHub (May 12, 2026): Adding a +1 on @da-astro's USER_AGENT finding. Worth flagging this clearly so it isn't missed in the v0.9.6 review cycle. The allow_redirects fix (PR #24602) addresses the immediate TypeError, but if shipped alone, real-world web search will still degrade on Cloudflare-protected sites, Wikipedia, and any host with bot detection — exactly the sites users hit most often. The python-requests UA gets blocked or rate-limited aggressively. Would strongly recommend merging both fixes together in v0.9.6 so users don't roll forward, find search "technically working" but empty on half the sites, and roll back again.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#74937