[GH-ISSUE #24243] bug: Yandex web search fails with NoneType error when XML response has missing fields #58907

Open
opened 2026-05-06 00:25:27 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @nikitavich on GitHub (Apr 29, 2026).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/24243

Summary

Web search via the Yandex provider (added in v0.9.x) fails with 'NoneType' object has no attribute 'text' whenever the Yandex Search API XML response contains a result document missing one of the fields the parser expects (<url>, <title>, <passages>/<passage>).

The error is silently swallowed inside search_yandex (only log.error is called) and the function returns an empty list, so the user-facing result is "No results found from web search" even though the Yandex API call itself succeeded with HTTP 200 and returned valid results.

Affected version

v0.9.0 – v0.9.2 (current main as of 2026-04-29 still has the bug).

Reproduction

  1. Configure Yandex as web search engine with valid API key (Yandex Cloud Search API v2)
  2. Send a query that triggers a multi-document response where at least one <group>/<doc> has no <passages>/<passage> child or has an empty <title>
  3. Search fails entirely

In our environment the failure was reliably triggered by Russian-language queries with broad intent. A direct call to https://searchapi.api.cloud.yandex.net/v2/web/search returned valid base64-encoded XML with 3 groups, but one group lacked <doc/passages/passage>, causing group.find('doc/passages/passage') to return None.

Stack trace

ERROR | open_webui.retrieval.web.yandex:search_yandex:117 - Error in search: 'NoneType' object has no attribute 'text'
ERROR | open_webui.utils.middleware:chat_web_search_handler:1651 - 404: [ERROR: No results found from web search]
fastapi.exceptions.HTTPException: 404: [ERROR: No results found from web search]

Root cause

In backend/open_webui/retrieval/web/yandex.py, the xml_element_contents_to_string helper accesses element.text unconditionally, but it is called with the result of group.find('doc/url') / doc/title / doc/passages/passage, any of which may return None when the corresponding XML node is absent in a particular result.

def xml_element_contents_to_string(element: Element) -> str:
    buffer = [element.text if element.text else '']  # <-- crashes if element is None
    ...

Suggested fix

Trivial one-liner — guard against None at the top of the helper:

def xml_element_contents_to_string(element: Element) -> str:
    if element is None:
        return ''
    buffer = [element.text if element.text else '']
    ...

Verified on our deployment: after applying this patch, the same query that previously returned no results now returns 5 valid results (championat.com, sports.ru, f1news.ru, avito.ru) without errors.

Happy to send a PR if it would help.

Environment

  • Open WebUI: v0.9.2 (Docker image ghcr.io/open-webui/open-webui:v0.9.2)
  • Search engine: Yandex (Yandex Cloud Search API v2, endpoint searchapi.api.cloud.yandex.net/v2/web/search)
  • Default config (no custom YANDEX_WEB_SEARCH_CONFIG), searchType: SEARCH_TYPE_RU
Originally created by @nikitavich on GitHub (Apr 29, 2026). Original GitHub issue: https://github.com/open-webui/open-webui/issues/24243 ## Summary Web search via the Yandex provider (added in v0.9.x) fails with `'NoneType' object has no attribute 'text'` whenever the Yandex Search API XML response contains a result document missing one of the fields the parser expects (`<url>`, `<title>`, `<passages>/<passage>`). The error is silently swallowed inside `search_yandex` (only `log.error` is called) and the function returns an empty list, so the user-facing result is **"No results found from web search"** even though the Yandex API call itself succeeded with HTTP 200 and returned valid results. ## Affected version v0.9.0 – v0.9.2 (current main as of 2026-04-29 still has the bug). ## Reproduction 1. Configure Yandex as web search engine with valid API key (Yandex Cloud Search API v2) 2. Send a query that triggers a multi-document response where at least one `<group>/<doc>` has no `<passages>/<passage>` child or has an empty `<title>` 3. Search fails entirely In our environment the failure was reliably triggered by Russian-language queries with broad intent. A direct call to `https://searchapi.api.cloud.yandex.net/v2/web/search` returned valid base64-encoded XML with 3 groups, but one group lacked `<doc/passages/passage>`, causing `group.find('doc/passages/passage')` to return `None`. ## Stack trace ``` ERROR | open_webui.retrieval.web.yandex:search_yandex:117 - Error in search: 'NoneType' object has no attribute 'text' ERROR | open_webui.utils.middleware:chat_web_search_handler:1651 - 404: [ERROR: No results found from web search] fastapi.exceptions.HTTPException: 404: [ERROR: No results found from web search] ``` ## Root cause In `backend/open_webui/retrieval/web/yandex.py`, the `xml_element_contents_to_string` helper accesses `element.text` unconditionally, but it is called with the result of `group.find('doc/url')` / `doc/title` / `doc/passages/passage`, any of which may return `None` when the corresponding XML node is absent in a particular result. ```python def xml_element_contents_to_string(element: Element) -> str: buffer = [element.text if element.text else ''] # <-- crashes if element is None ... ``` ## Suggested fix Trivial one-liner — guard against `None` at the top of the helper: ```python def xml_element_contents_to_string(element: Element) -> str: if element is None: return '' buffer = [element.text if element.text else ''] ... ``` Verified on our deployment: after applying this patch, the same query that previously returned no results now returns 5 valid results (championat.com, sports.ru, f1news.ru, avito.ru) without errors. Happy to send a PR if it would help. ## Environment - Open WebUI: v0.9.2 (Docker image `ghcr.io/open-webui/open-webui:v0.9.2`) - Search engine: Yandex (Yandex Cloud Search API v2, endpoint `searchapi.api.cloud.yandex.net/v2/web/search`) - Default config (no custom `YANDEX_WEB_SEARCH_CONFIG`), `searchType: SEARCH_TYPE_RU`
Author
Owner

@pr-validator-bot commented on GitHub (Apr 29, 2026):

⚠️ Missing Issue Title Prefix

@nikitavich, your issue title is missing a prefix (e.g., bug:, feat:, docs:).

Please update your issue title to include one of the following prefixes:

  • bug: Bug report or error you've encountered
  • feat: Feature request or enhancement suggestion
  • docs: Documentation issue or improvement request
  • question: Question about usage or functionality
  • help: Request for help or support

Example: bug: Login fails when using special characters in password

<!-- gh-comment-id:4346096240 --> @pr-validator-bot commented on GitHub (Apr 29, 2026): # ⚠️ Missing Issue Title Prefix @nikitavich, your issue title is missing a prefix (e.g., `bug:`, `feat:`, `docs:`). Please update your issue title to include one of the following prefixes: - **bug**: Bug report or error you've encountered - **feat**: Feature request or enhancement suggestion - **docs**: Documentation issue or improvement request - **question**: Question about usage or functionality - **help**: Request for help or support Example: `bug: Login fails when using special characters in password`
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#58907