mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-06 10:58:17 -05:00
[PR #22118] [CLOSED] fix: add type guards in citation parser to prevent AttributeError #42131
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/22118
Author: @umut-polat
Created: 3/1/2026
Status: ❌ Closed
Base:
dev← Head:fix/citation-parser-type-guard-v2📝 Commits (1)
02682c6fix: add type guards in citation parser to prevent AttributeError📊 Changes
1 file changed (+6 additions, -0 deletions)
View changed files
📝
backend/open_webui/utils/middleware.py(+6 -0)📄 Description
Pull Request Checklist
dev[]instead of crashingChangelog Entry
Description
When a tool (e.g.
search_web) returns an error string instead of the expected data structure,get_citation_source_from_tool_resultcrashes withAttributeError: 'str' object has no attribute 'get'. This happens because the JSON parse failure silently falls through, leavingtool_resultas a plain string.Fixed
isinstancetype guards inget_citation_source_from_tool_resultfor three tool branches:search_web: checks result is alistbefore iteratingview_knowledge_file: checks result is adictbefore calling.get()query_knowledge_files: checks result is alistbefore iteratingFixes #21070
Additional Information
Previous PRs (#21638, #21209, #21207, #21244, #21250) attempted to fix this but were closed. The root cause is still present in the current codebase — the
isinstanceguards are the minimal defensive fix.Contributor License Agreement
By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.