[PR #20344] [CLOSED] fix: workspace models returning "Model not found" error #129234

Closed
opened 2026-05-21 12:23:03 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

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

Base: devHead: fix-db


📝 Commits (1)

📊 Changes

2 files changed (+6 additions, -0 deletions)

View changed files

📝 backend/open_webui/routers/ollama.py (+3 -0)
📝 backend/open_webui/routers/openai.py (+3 -0)

📄 Description

Problem

Workspace models (custom models created via Workspace > Models) were returning "Model not found" (404) errors when attempting to chat with them.

https://github.com/open-webui/open-webui/issues/20340

Root Cause

When the generate_chat_completion functions in openai.py and ollama.py are called internally from chat.py (not via HTTP), the db parameter defaults to a Depends(get_session) object rather than an actual Session. This Depends object is truthy, so get_db_context attempted to use it as a session, causing Models.get_model_by_id to fail silently and return None.

With model_info being None, the base_model_id resolution was skipped, and the workspace model ID was passed directly to the API instead of its underlying base model.

Solution

Added a check in both openai.py and ollama.py to verify that db is an actual Session instance before using it. If not, db is set to None so get_db_context creates a fresh session.

Changes

  • openai.py: Added isinstance check for db parameter in generate_chat_completion
  • ollama.py: Added isinstance check for db parameter in generate_chat_completion

@tjbck

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/20344 **Author:** [@Classic298](https://github.com/Classic298) **Created:** 1/3/2026 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `fix-db` --- ### 📝 Commits (1) - [`6a17cee`](https://github.com/open-webui/open-webui/commit/6a17cee84629d63792b92d36a624d5852d3b17bf) fix ### 📊 Changes **2 files changed** (+6 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/routers/ollama.py` (+3 -0) 📝 `backend/open_webui/routers/openai.py` (+3 -0) </details> ### 📄 Description ### Problem Workspace models (custom models created via Workspace > Models) were returning "Model not found" (404) errors when attempting to chat with them. https://github.com/open-webui/open-webui/issues/20340 ### Root Cause When the generate_chat_completion functions in openai.py and ollama.py are called internally from chat.py (not via HTTP), the db parameter defaults to a Depends(get_session) object rather than an actual Session. This Depends object is truthy, so get_db_context attempted to use it as a session, causing Models.get_model_by_id to fail silently and return None. With model_info being None, the base_model_id resolution was skipped, and the workspace model ID was passed directly to the API instead of its underlying base model. ### Solution Added a check in both openai.py and ollama.py to verify that db is an actual Session instance before using it. If not, db is set to None so get_db_context creates a fresh session. ### Changes - openai.py: Added isinstance check for db parameter in generate_chat_completion - ollama.py: Added isinstance check for db parameter in generate_chat_completion @tjbck ### 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-21 12:23:03 -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#129234