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

Closed
opened 2026-05-06 10:14:50 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

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

Base: mainHead: fix-model-capabilities-none-check


📝 Commits (3)

  • f84aad5 fix: handle None value for model capabilities in builtin_tools check
  • 0d4898f fix: handle None value for model capabilities in file_context check
  • 9772be0 fix: handle None value for capabilities in get_model_capability helper

📊 Changes

2 files changed (+5 additions, -7 deletions)

View changed files

📝 backend/open_webui/utils/middleware.py (+4 -6)
📝 backend/open_webui/utils/tools.py (+1 -1)

📄 Description

Summary

Fixes #20565

When model.info.meta.capabilities is None (null), the code crashes with:

AttributeError: 'NoneType' object has no attribute 'get'

Root Cause

The dict.get(key, default) method returns the value if the key exists, even if that value is None. The default value is only used when the key is missing. So .get("capabilities", {}) returns None when the capabilities key exists but has value None, rather than returning the default {}.

Changes

  • Modified backend/open_webui/utils/middleware.py (2 locations)
    • Fixed builtin_tools_enabled check at line 1813
    • Fixed file_context_enabled check at line 1860
  • Modified backend/open_webui/utils/tools.py
    • Fixed get_model_capability() helper function at line 402
  • Changed .get("capabilities", {}) to .get("capabilities") or {} in all 3 locations
  • This ensures None values are treated as empty dict

Test

Manual testing confirmed:

  • When capabilities is None → or {} returns {} → .get() returns default value
  • When capabilities is {} → .get() returns default value
  • When capabilities has explicit values → .get() returns those values

The fix preserves default behavior (True for both builtin_tools and file_context when not specified) while preventing the AttributeError crash.

Checklist

  • Code follows project style
  • Fix is minimal and focused
  • No new dependencies added
  • All instances of the pattern in codebase are fixed
  • Manual testing completed

🔄 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/20743 **Author:** [@YuriNachos](https://github.com/YuriNachos) **Created:** 1/17/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix-model-capabilities-none-check` --- ### 📝 Commits (3) - [`f84aad5`](https://github.com/open-webui/open-webui/commit/f84aad5f141ab769d4b75628f576c89c9ff88db9) fix: handle None value for model capabilities in builtin_tools check - [`0d4898f`](https://github.com/open-webui/open-webui/commit/0d4898fa40798e396c4deb2f9cc71b0b7d54baf4) fix: handle None value for model capabilities in file_context check - [`9772be0`](https://github.com/open-webui/open-webui/commit/9772be02cc1d4b4153a76fd15a12d07d47f8eb66) fix: handle None value for capabilities in get_model_capability helper ### 📊 Changes **2 files changed** (+5 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/utils/middleware.py` (+4 -6) 📝 `backend/open_webui/utils/tools.py` (+1 -1) </details> ### 📄 Description ## Summary Fixes #20565 When model.info.meta.capabilities is None (null), the code crashes with: ``` AttributeError: 'NoneType' object has no attribute 'get' ``` ## Root Cause The dict.get(key, default) method returns the value if the key exists, even if that value is None. The default value is only used when the key is missing. So `.get("capabilities", {})` returns None when the capabilities key exists but has value None, rather than returning the default {}. ## Changes - Modified `backend/open_webui/utils/middleware.py` (2 locations) - Fixed `builtin_tools_enabled` check at line 1813 - Fixed `file_context_enabled` check at line 1860 - Modified `backend/open_webui/utils/tools.py` - Fixed `get_model_capability()` helper function at line 402 - Changed `.get("capabilities", {})` to `.get("capabilities") or {}` in all 3 locations - This ensures None values are treated as empty dict ## Test Manual testing confirmed: - When capabilities is None → or {} returns {} → .get() returns default value - When capabilities is {} → .get() returns default value - When capabilities has explicit values → .get() returns those values The fix preserves default behavior (True for both builtin_tools and file_context when not specified) while preventing the AttributeError crash. ## Checklist - [x] Code follows project style - [x] Fix is minimal and focused - [x] No new dependencies added - [x] All instances of the pattern in codebase are fixed - [x] Manual testing completed --- <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:14:50 -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#64612