In backend/open_webui/retrieval/web/yandex.py, the xml_element_contents_to_string() helper receives element: Element but is called with the result of group.find('doc/url'), group.find('doc/title'), or group.find('doc/passages/passage'), any of which may return None when the corresponding XML node is absent.
When element is None, accessing element.text raises:
AttributeError: 'NoneType' object has no attribute 'text'
This crashes the entire search function, which then silently returns [], so users see "No results found" even though the Yandex API returned valid results.
Stack trace from the issue:
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]
The function already handles the case of element.text being None (using ''), so this change is consistent with the existing pattern.
Impact
Search now returns partial results instead of crashing when individual XML nodes are missing
No behavior change for well-formed Yandex API responses
The search_yandex function already has try/except and returns [] on error, so this is a defensive improvement
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.
## 📋 Pull Request Information
**Original PR:** https://github.com/open-webui/open-webui/pull/24256
**Author:** [@PHclaw](https://github.com/PHclaw)
**Created:** 4/30/2026
**Status:** ❌ Closed
**Base:** `main` ← **Head:** `fix/yandex-xml-none-check`
---
### 📝 Commits (1)
- [`5effec6`](https://github.com/open-webui/open-webui/commit/5effec6a2ab203e83f6a60db7ff2e29174aec094) fix(web): guard xml_element_contents_to_string against None
### 📊 Changes
**1 file changed** (+3 additions, -1 deletions)
<details>
<summary>View changed files</summary>
📝 `backend/open_webui/retrieval/web/yandex.py` (+3 -1)
</details>
### 📄 Description
## Summary
Fixes #24243
## Bug
In `backend/open_webui/retrieval/web/yandex.py`, the `xml_element_contents_to_string()` helper receives `element: Element` but is called with the result of `group.find('doc/url')`, `group.find('doc/title')`, or `group.find('doc/passages/passage')`, any of which may return `None` when the corresponding XML node is absent.
When `element is None`, accessing `element.text` raises:
```
AttributeError: 'NoneType' object has no attribute 'text'
```
This crashes the entire search function, which then silently returns `[]`, so users see "No results found" even though the Yandex API returned valid results.
Stack trace from the issue:
```
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]
```
## Fix
Guard against `None` at the top of the helper:
```python
def xml_element_contents_to_string(element: Element | None) -> str:
if element is None:
return ''
buffer = [element.text if element.text else '']
...
```
The function already handles the case of `element.text` being `None` (using `''`), so this change is consistent with the existing pattern.
## Impact
- Search now returns partial results instead of crashing when individual XML nodes are missing
- No behavior change for well-formed Yandex API responses
- The `search_yandex` function already has `try/except` and returns `[]` on error, so this is a defensive improvement
---
<sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/24256
Author: @PHclaw
Created: 4/30/2026
Status: ❌ Closed
Base:
main← Head:fix/yandex-xml-none-check📝 Commits (1)
5effec6fix(web): guard xml_element_contents_to_string against None📊 Changes
1 file changed (+3 additions, -1 deletions)
View changed files
📝
backend/open_webui/retrieval/web/yandex.py(+3 -1)📄 Description
Summary
Fixes #24243
Bug
In
backend/open_webui/retrieval/web/yandex.py, thexml_element_contents_to_string()helper receiveselement: Elementbut is called with the result ofgroup.find('doc/url'),group.find('doc/title'), orgroup.find('doc/passages/passage'), any of which may returnNonewhen the corresponding XML node is absent.When
element is None, accessingelement.textraises:This crashes the entire search function, which then silently returns
[], so users see "No results found" even though the Yandex API returned valid results.Stack trace from the issue:
Fix
Guard against
Noneat the top of the helper:The function already handles the case of
element.textbeingNone(using''), so this change is consistent with the existing pattern.Impact
search_yandexfunction already hastry/exceptand returns[]on error, so this is a defensive improvement🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.