mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-07 03:18:23 -05:00
[GH-ISSUE #12318] issue: Config Attributes Not Loaded from Database, Causing AttributeError #32080
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?
Originally created by @kingofbergen on GitHub (Apr 1, 2025).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/12318
Check Existing Issues
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
README.md.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.