When web search fails and returns an error string instead of a valid JSON list, the citation parser crashes with AttributeError: 'str' object has no attribute 'get'.
Changes
Added type check in get_citation_source_from_tool_result function
Returns empty list when search_web result is not a valid list
Issue
Fixes#21070 - AttributeError: 'str' object has no attribute 'get' in citation parser when web search fails
🔄 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/22308
**Author:** [@fskeung](https://github.com/fskeung)
**Created:** 3/6/2026
**Status:** ❌ Closed
**Base:** `main` ← **Head:** `fix/search-web-citation-error`
---
### 📝 Commits (2)
- [`426b314`](https://github.com/open-webui/open-webui/commit/426b314330cd0e35b87308376cf0258176c57045) fix: Clear selected tools when switching models
- [`44461a2`](https://github.com/open-webui/open-webui/commit/44461a227d620efc92a62dc3dda1765d12aeb19c) fix: Handle search_web error case in citation parser
### 📊 Changes
**2 files changed** (+7 additions, -3 deletions)
<details>
<summary>View changed files</summary>
📝 `backend/open_webui/utils/middleware.py` (+5 -0)
📝 `src/lib/components/chat/Chat.svelte` (+2 -3)
</details>
### 📄 Description
## Summary
When web search fails and returns an error string instead of a valid JSON list, the citation parser crashes with `AttributeError: 'str' object has no attribute 'get'`.
## Changes
- Added type check in `get_citation_source_from_tool_result` function
- Returns empty list when search_web result is not a valid list
## Issue
Fixes #21070 - AttributeError: 'str' object has no attribute 'get' in citation parser when web search fails
---
<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/22308
Author: @fskeung
Created: 3/6/2026
Status: ❌ Closed
Base:
main← Head:fix/search-web-citation-error📝 Commits (2)
426b314fix: Clear selected tools when switching models44461a2fix: Handle search_web error case in citation parser📊 Changes
2 files changed (+7 additions, -3 deletions)
View changed files
📝
backend/open_webui/utils/middleware.py(+5 -0)📝
src/lib/components/chat/Chat.svelte(+2 -3)📄 Description
Summary
When web search fails and returns an error string instead of a valid JSON list, the citation parser crashes with
AttributeError: 'str' object has no attribute 'get'.Changes
get_citation_source_from_tool_resultfunctionIssue
Fixes #21070 - AttributeError: 'str' object has no attribute 'get' in citation parser when web search fails
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.