mirror of
https://github.com/open-webui/open-webui.git
synced 2026-07-10 23:55:15 -05:00
[GH-ISSUE #21315] issue: Title: [BUG/FIX] IndexError in save_docs_to_vector_db and lack of retry logic for embedding generation #106436
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 @DaMccRee on GitHub (Feb 12, 2026).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/21315
Check Existing Issues
Installation Method
Docker
Open WebUI Version
Open WebUI Version: Latest / Dev 0.7.2
Ollama Version (if applicable)
ollama latest
Operating System
Ubuntu 22.04
Browser (if applicable)
chrome latest
Confirmation
README.md.Expected Behavior
IndexError.Actual Behavior
When processing large files or under high load,
open-webuican encounter anIndexError: list index out of rangeduring the embedding saving process. This occurs because the embedding generation for certain batches might fail (e.g., due to a 503 Service Unavailable from Ollama or network timeouts), and the current implementation silently continues with a mismatched number of embeddings and text chunks.Additionally, the asynchronous embedding functions lack a retry mechanism, making the RAG pipeline fragile when using external or local LLM services (like Ollama/OpenAI) that may experience transient failures.
Steps to Reproduce
texts, leading to theIndexErrorwhen constructing the vector DB items.Logs & Screenshots
File "/app/backend/open_webui/routers/retrieval.py", line 1750, in process_file
result = save_docs_to_vector_db(...)
File "/app/backend/open_webui/routers/retrieval.py", line 1555, in
"vector": embeddings[idx],
IndexError: list index out of range
Additional Information
Proposed Solution
1. Fix the Mismatch (IndexError Management)
In
open_webui/routers/retrieval.py, a length check should be added before the list comprehension to ensureembeddingsandtextsare aligned. If a mismatch is detected, an explicit exception should be raised.In
open_webui/retrieval/utils.py->get_embedding_function, ensure that if any batch fails to return a valid list, the entire process raises an exception instead of extending the list withNoneor skipping.2. Implement Retry Logic with Exponential Backoff
The async embedding functions (
agenerate_ollama_batch_embeddings,agenerate_openai_batch_embeddings, andagenerate_azure_openai_batch_embeddings) should be wrapped with a retry mechanism.Key Changes Recommended:
max_retriesloop (e.g., 3-5 attempts).asyncio.sleepbetween retries.Implementation Example:
Benefit
IndexError, administrators can see "Failed to generate embeddings after X attempts" in the logs, pointing directly to the embedding engine issue.@DaMccRee commented on GitHub (Feb 12, 2026):
Technical Deep Dive & Validation (Supplemental)
Root Cause Analysis
The
IndexErroris a secondary symptom. The primary cause is thatget_embedding_function(inretrieval/utils.py) processes embeddings in batches. Currently, if any batch fails (e.g., Ollama returning 503 during model loading), the system may continue with a mismatched number of embeddings versus text chunks.Later,
save_docs_to_vector_dbiterates over the originaltextslength, but since theembeddingslist is shorter, it triggers theIndexError.Effectiveness of the Solution
retrieval.pyto prevent theIndexErrorand provide a meaningful error message.utils.py. This ensures that transient network issues or service overloads (like Ollama loading a model) don't crash the entire document processing pipeline.Validation Results
In testing, the system now successfully handles transient Ollama 503 errors:
Readiness for Pull Request
The proposed changes have been verified in a production-like Docker environment. This fix maintains data consistency and significantly improves the robustness of the RAG pipeline.
@DaMccRee commented on GitHub (Feb 13, 2026):
Ok
发自我的 iPhone
在 2026年2月13日,上午5:38,Tim Baek @.***> 写道:
Closed #21315https://github.com/open-webui/open-webui/issues/21315 as not planned.
—
Reply to this email directly, view it on GitHubhttps://github.com/open-webui/open-webui/issues/21315#event-22748772503, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AZRS6UWYUGMDUO47HG4XVK34LTXFTAVCNFSM6AAAAACU2QEJBGVHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMRSG42DQNZXGI2TAMY.
You are receiving this because you authored the thread.Message ID: @.***>