[GH-ISSUE #12318] issue: Config Attributes Not Loaded from Database, Causing AttributeError #16551

Closed
opened 2026-04-19 22:26:52 -05:00 by GiteaMirror · 0 comments
Owner

Originally created by @kingofbergen on GitHub (Apr 1, 2025).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/12318

Check Existing Issues

  • I have searched the existing issues and discussions.
  • I am using the latest version of Open WebUI.

Installation Method

Git Clone

Open WebUI Version

v0.6.0

Ollama Version (if applicable)

No response

Operating System

Debian 6.1

Browser (if applicable)

No response

Confirmation

  • I have read and followed all instructions in README.md.
  • I am using the latest version of both Open WebUI and Ollama.
  • I have included the browser console logs.
  • I have included the Docker container logs.
  • I have listed steps to reproduce the bug in detail.

Expected Behavior

The AppConfig object (request.app.state.config) fails to load attributes from the database (webui.db) in some setups, leading to AttributeError: Config key '' not found in retrieval.py. This occurs despite the correct config JSON being present in the database, affecting keys like DOCLING_SERVER_URL, TOP_K_RERANKER, and YOUTUBE_LOADER_TRANSLATION.

Expected Behavior
request.app.state.config.DOCLING_SERVER_URL, .TOP_K_RERANKER, etc., should reflect the database values or environment variables.
Endpoints return 200 with config data.

Actual Behavior

AttributeError: Config key 'DOCLING_SERVER_URL' not found (and similar for other keys) in retrieval.py:
Line 362: "docling_server_url": request.app.state.config.DOCLING_SERVER_URL
Line 735: "k_reranker": request.app.state.config.TOP_K_RERANKER
Debug logs show request.app.state.config.dict lacks expected keys:

Config state attributes: ['annotations', 'class', ..., '_redis', '_state']
Config DOCLING_SERVER_URL: Not found
Config rag attribute: Not found

open-webui | File "/app/backend/open_webui/routers/retrieval.py", line 362, in get_rag_config
open-webui | "docling_server_url": request.app.state.config.DOCLING_SERVER_URL,
open-webui | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
open-webui | File "/app/backend/open_webui/config.py", line 281, in getattr
open-webui | raise AttributeError(f"Config key '{key}' not found")
open-webui | AttributeError: Config key 'DOCLING_SERVER_URL' not found

Steps to Reproduce

docker-compose.yml
services:
open-webui:
image: ghcr.io/open-webui/open-webui:v0.6.0
environment:
- DOCLING_SERVER_URL=""
volumes:
- ./open-webui-data:/app/backend/data

check webui.db
SELECT * FROM config WHERE id = 1;
-- Example output: {"rag": {"docling_server_url": """", "top_k_reranker": 3, "youtube_loader_language": ["en"]}}

Check https://localhost:3000/admin/settings + click Documents

Logs & Screenshots

open-webui | File "/app/backend/open_webui/routers/retrieval.py", line 362, in get_rag_config
open-webui | "docling_server_url": request.app.state.config.DOCLING_SERVER_URL,
open-webui | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
open-webui | File "/app/backend/open_webui/config.py", line 281, in getattr
open-webui | raise AttributeError(f"Config key '{key}' not found")
open-webui | AttributeError: Config key 'DOCLING_SERVER_URL' not found

+layout.svelte:507 Backend config: Object
+layout.svelte:77 connected IesIXS63XBcTnlV3AAAL
+layout.svelte:96 user-list Object
+layout.svelte:101 usage Object
+layout.svelte:96 user-list Object
+layout.svelte:202 Object
index.ts:45 SyntaxError: Unexpected token 'I', "Internal S"... is not valid JSON
General.svelte:61 Object
General.svelte:64 false
index.ts:134 SyntaxError: Unexpected token 'I', "Internal S"... is not valid JSON
Documents.svelte:675 Uncaught (in promise) TypeError: Cannot read properties of null (reading 'hybrid')
at Object.p (Documents.svelte:675:36)
at Object.p (Documents.svelte:670:28)
at Object.p (Documents.svelte:475:40)
at dt (scheduler.js:119:30)
at _t (scheduler.js:79:5)
p @ Documents.svelte:675
p @ Documents.svelte:670
p @ Documents.svelte:475
dt @ scheduler.js:119
_t @ scheduler.js:79
Promise.then
ut @ scheduler.js:20
ht @ Component.js:81
(anonymous) @ Component.js:139
(anonymous) @ Documents.svelte:262
await in (anonymous)
J @ utils.js:41
(anonymous) @ Component.js:47
_t @ scheduler.js:99
Promise.then
ut @ scheduler.js:20
ht @ Component.js:81
(anonymous) @ Component.js:139
i @ Settings.svelte:144Understand this errorAI
index.ts:18 SyntaxError: Unexpected token 'I', "Internal S"... is not valid JSON

Additional Information

Root Cause
AppConfig._state isn’t populated with PersistentConfig objects from webui.db’s config table.
config.py’s getattr raises AttributeError when keys are missing from _state, with no fallback or nested lookup (e.g., rag.docling_server_url).
Works on some servers but fails on others, suggesting an initialization or database sync issue in main.py or config.py.

Workaround
Added fallbacks in retrieval.py:

docling_server_url = getattr(request.app.state.config, 'DOCLING_SERVER_URL', os.environ.get('DOCLING_SERVER_URL', ''))
top_k_reranker = getattr(request.app.state.config, 'TOP_K_RERANKER', 3)
youtube_translation = getattr(request.app.state.config, 'YOUTUBE_LOADER_TRANSLATION', None)

Suggested Fix
In main.py, verify AppConfig is initialized with all PersistentConfig objects after get_config() loads webui.db.
Log CONFIG_DATA after get_config() to confirm database read.

Enhance AppConfig
Modify getattr to check nested rag structure or provide defaults:

def getattr(self, key):
if key in self._state:
return self._state[key].value
if hasattr(self, 'rag') and hasattr(self.rag, key.lower()):
return getattr(self.rag, key.lower())
return os.environ.get(key, None) # Or sensible default

Fallbacks in retrieval.py: Add getattr defaults as a safety net.

Impact
Breaks RAG-related endpoints (/retrieval/config, /query/settings) unless patched, affecting usability in inconsistent deployments.

Originally created by @kingofbergen on GitHub (Apr 1, 2025). Original GitHub issue: https://github.com/open-webui/open-webui/issues/12318 ### Check Existing Issues - [x] I have searched the existing issues and discussions. - [x] I am using the latest version of Open WebUI. ### Installation Method Git Clone ### Open WebUI Version v0.6.0 ### Ollama Version (if applicable) _No response_ ### Operating System Debian 6.1 ### Browser (if applicable) _No response_ ### Confirmation - [x] I have read and followed all instructions in `README.md`. - [x] I am using the latest version of **both** Open WebUI and Ollama. - [x] I have included the browser console logs. - [x] I have included the Docker container logs. - [x] I have listed steps to reproduce the bug in detail. ### Expected Behavior The AppConfig object (request.app.state.config) fails to load attributes from the database (webui.db) in some setups, leading to AttributeError: Config key '<key>' not found in retrieval.py. This occurs despite the correct config JSON being present in the database, affecting keys like DOCLING_SERVER_URL, TOP_K_RERANKER, and YOUTUBE_LOADER_TRANSLATION. Expected Behavior request.app.state.config.DOCLING_SERVER_URL, .TOP_K_RERANKER, etc., should reflect the database values or environment variables. Endpoints return 200 with config data. ### Actual Behavior AttributeError: Config key 'DOCLING_SERVER_URL' not found (and similar for other keys) in retrieval.py: Line 362: "docling_server_url": request.app.state.config.DOCLING_SERVER_URL Line 735: "k_reranker": request.app.state.config.TOP_K_RERANKER Debug logs show request.app.state.config.__dict__ lacks expected keys: Config state attributes: ['__annotations__', '__class__', ..., '_redis', '_state'] Config DOCLING_SERVER_URL: Not found Config rag attribute: Not found open-webui | File "/app/backend/open_webui/routers/retrieval.py", line 362, in get_rag_config open-webui | "docling_server_url": request.app.state.config.DOCLING_SERVER_URL, open-webui | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ open-webui | File "/app/backend/open_webui/config.py", line 281, in __getattr__ open-webui | raise AttributeError(f"Config key '{key}' not found") open-webui | AttributeError: Config key 'DOCLING_SERVER_URL' not found ### Steps to Reproduce docker-compose.yml services: open-webui: image: ghcr.io/open-webui/open-webui:v0.6.0 environment: - DOCLING_SERVER_URL="" volumes: - ./open-webui-data:/app/backend/data check webui.db SELECT * FROM config WHERE id = 1; -- Example output: {"rag": {"docling_server_url": "\"\"", "top_k_reranker": 3, "youtube_loader_language": ["en"]}} Check https://localhost:3000/admin/settings + click Documents ### Logs & Screenshots open-webui | File "/app/backend/open_webui/routers/retrieval.py", line 362, in get_rag_config open-webui | "docling_server_url": request.app.state.config.DOCLING_SERVER_URL, open-webui | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ open-webui | File "/app/backend/open_webui/config.py", line 281, in __getattr__ open-webui | raise AttributeError(f"Config key '{key}' not found") open-webui | AttributeError: Config key 'DOCLING_SERVER_URL' not found +layout.svelte:507 Backend config: Object +layout.svelte:77 connected IesIXS63XBcTnlV3AAAL +layout.svelte:96 user-list Object +layout.svelte:101 usage Object +layout.svelte:96 user-list Object +layout.svelte:202 Object index.ts:45 SyntaxError: Unexpected token 'I', "Internal S"... is not valid JSON General.svelte:61 Object General.svelte:64 false index.ts:134 SyntaxError: Unexpected token 'I', "Internal S"... is not valid JSON Documents.svelte:675 Uncaught (in promise) TypeError: Cannot read properties of null (reading 'hybrid') at Object.p (Documents.svelte:675:36) at Object.p (Documents.svelte:670:28) at Object.p (Documents.svelte:475:40) at dt (scheduler.js:119:30) at _t (scheduler.js:79:5) p @ Documents.svelte:675 p @ Documents.svelte:670 p @ Documents.svelte:475 dt @ scheduler.js:119 _t @ scheduler.js:79 Promise.then ut @ scheduler.js:20 ht @ Component.js:81 (anonymous) @ Component.js:139 (anonymous) @ Documents.svelte:262 await in (anonymous) J @ utils.js:41 (anonymous) @ Component.js:47 _t @ scheduler.js:99 Promise.then ut @ scheduler.js:20 ht @ Component.js:81 (anonymous) @ Component.js:139 i @ Settings.svelte:144Understand this errorAI index.ts:18 SyntaxError: Unexpected token 'I', "Internal S"... is not valid JSON ### Additional Information Root Cause AppConfig._state isn’t populated with PersistentConfig objects from webui.db’s config table. config.py’s __getattr__ raises AttributeError when keys are missing from _state, with no fallback or nested lookup (e.g., rag.docling_server_url). Works on some servers but fails on others, suggesting an initialization or database sync issue in main.py or config.py. Workaround Added fallbacks in retrieval.py: docling_server_url = getattr(request.app.state.config, 'DOCLING_SERVER_URL', os.environ.get('DOCLING_SERVER_URL', '')) top_k_reranker = getattr(request.app.state.config, 'TOP_K_RERANKER', 3) youtube_translation = getattr(request.app.state.config, 'YOUTUBE_LOADER_TRANSLATION', None) Suggested Fix In main.py, verify AppConfig is initialized with all PersistentConfig objects after get_config() loads webui.db. Log CONFIG_DATA after get_config() to confirm database read. Enhance AppConfig Modify __getattr__ to check nested rag structure or provide defaults: def __getattr__(self, key): if key in self._state: return self._state[key].value if hasattr(self, 'rag') and hasattr(self.rag, key.lower()): return getattr(self.rag, key.lower()) return os.environ.get(key, None) # Or sensible default Fallbacks in retrieval.py: Add getattr defaults as a safety net. Impact Breaks RAG-related endpoints (/retrieval/config, /query/settings) unless patched, affecting usability in inconsistent deployments.
GiteaMirror added the bug label 2026-04-19 22:26:52 -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#16551