[PR #20753] [CLOSED] fix: Handle None value for model metadata capabilities field (#20565) #64622

Closed
opened 2026-05-06 10:15:43 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/20753
Author: @Classic298
Created: 1/17/2026
Status: Closed

Base: devHead: fix-none-capability


📝 Commits (1)

  • 2f3f098 fix: handle None value for capabilities

📊 Changes

1 file changed (+6 additions, -1 deletions)

View changed files

📝 backend/open_webui/models/models.py (+6 -1)

📄 Description

Tested locally, works

Fixes https://github.com/open-webui/open-webui/issues/20565

Solution

Added a Pydantic field_validator to the ModelMeta class that normalizes None to an empty dict during deserialization. This fixes the issue at the data source, so all existing and future code paths automatically receive a valid dict instead of None.
The fix is applied at read-time, so existing models with null capabilities in the database are automatically corrected when loaded - no database migration required.

Changes

  • Added field_validator import from pydantic
  • Added capabilities_none_to_empty validator to ModelMeta class

Testing

Verified that ModelMeta(capabilities=None).capabilities returns {} and subsequent .get() calls work correctly.

Prevents

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.

Note

Deleting the CLA section will lead to immediate closure of your PR and it will not be merged in.


🔄 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/20753 **Author:** [@Classic298](https://github.com/Classic298) **Created:** 1/17/2026 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `fix-none-capability` --- ### 📝 Commits (1) - [`2f3f098`](https://github.com/open-webui/open-webui/commit/2f3f098e82f9b7a9727f968a3031cc5b153eecdc) fix: handle None value for capabilities ### 📊 Changes **1 file changed** (+6 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/models/models.py` (+6 -1) </details> ### 📄 Description Tested locally, works Fixes https://github.com/open-webui/open-webui/issues/20565 ### Solution Added a Pydantic field_validator to the ModelMeta class that normalizes None to an empty dict during deserialization. This fixes the issue at the data source, so all existing and future code paths automatically receive a valid dict instead of None. <ins>**The fix is applied at read-time, so existing models with null capabilities in the database are automatically corrected when loaded - no database migration required.**</ins> ### Changes - Added field_validator import from pydantic - Added capabilities_none_to_empty validator to ModelMeta class ### Testing Verified that ModelMeta(capabilities=None).capabilities returns {} and subsequent .get() calls work correctly. Prevents ### Contributor License Agreement By submitting this pull request, I confirm that I have read and fully agree to the [Contributor License Agreement (CLA)](https://github.com/open-webui/open-webui/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT), and I am providing my contributions under its terms. > [!NOTE] > Deleting the CLA section will lead to immediate closure of your PR and it will not be merged in. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-05-06 10:15:43 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#64622