mirror of
https://github.com/open-webui/open-webui.git
synced 2026-06-09 03:01:34 -05:00
[PR #21249] [CLOSED] fix: validate and normalize model tags to prevent UI crash #113304
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/21249
Author: @veeceey
Created: 2/8/2026
Status: ❌ Closed
Base:
dev← Head:fix/issue-20819-model-tags-validation-v2📝 Commits (2)
289daf4fix: validate model tags to prevent UI crash on malformed input32e3c7ffix: remove extra blank line to pass black formatting check📊 Changes
2 files changed (+25 additions, -6 deletions)
View changed files
📝
backend/open_webui/models/models.py(+15 -2)📝
backend/open_webui/routers/models.py(+10 -4)📄 Description
Pull Request Checklist
devbranch.fix:to categorize this pull request.Changelog Entry
Description
Fixes model tags validation so the
/api/modelsendpoint and/api/v1/models/tagsdon't crash when tags are stored as plain strings (e.g.,["tag1", "tag2"]) instead of the expected[{"name": "tag1"}]format. Adds a Pydanticmodel_validatortoModelMetathat normalizes string tags to dict format on input, and adds defensive type checking inget_model_tagsto handle both formats gracefully.Supersedes #21235 (closed due to missing CLA and wrong target branch).
Fixes #20819
Changed
backend/open_webui/models/models.py:model_validatortoModelMetaclass that normalizes string tags to dict format{"name": "tag"}on inputbackend/open_webui/apps/webui/routers/models.py:get_model_tags()to handle both string and dict tag formatsFixed
AttributeError: 'str' object has no attribute 'get'crash when model tags are stored as plain strings/api/modelsendpoint that caused infinite loading state in UIAdditional Information
Root Cause
Direct API calls to
/api/v1/models/model/updatecan save tags in any format since there's no backend validation. When incorrectly formatted tags (plain strings) are stored, theget_model_tagsendpoint crashes withAttributeError: 'str' object has no attribute 'get'becausetag.get('name')fails on string objects. This causes a 500 error on the models list API, leaving the UI stuck in an infinite loading state.Solution Approach
Two-layer defense:
get_model_tagshandles existing malformed data gracefullyScreenshots or Videos
Test Results
Before fix: API call with string tags causes 500 Internal Server Error, UI shows infinite loading.
After fix: String tags are auto-normalized to the correct format. Existing data with string tags is handled gracefully.
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.