[GH-ISSUE #18096] issue: ValueError crash in hybrid search when reranking filters out all results #138216

Closed
opened 2026-05-25 09:47:15 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @hazemawadalla on GitHub (Oct 7, 2025).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/18096

Check Existing Issues

  • I have searched for any existing and/or related issues.
  • I have searched for any existing and/or related discussions.
  • I am using the latest version of Open WebUI.

Installation Method

Git Clone

Open WebUI Version

0.6.32

Ollama Version (if applicable)

No response

Operating System

Ubuntu 24.04

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 provided every relevant configuration, setting, and environment variable used in my setup.
  • I have clearly listed every relevant configuration, custom setting, environment variable, and command-line option that influences my setup (such as Docker Compose overrides, .env values, browser settings, authentication configurations, etc).
  • I have documented step-by-step reproduction instructions that are precise, sequential, and leave nothing to interpretation. My steps:
  • Start with the initial platform/version/OS and dependencies used,
  • Specify exact install/launch/configure commands,
  • List URLs visited, user input (incl. example values/emails/passwords if needed),
  • Describe all options and toggles enabled or changed,
  • Include any files or environmental changes,
  • Identify the expected and actual result at each stage,
  • Ensure any reasonably skilled user can follow and hit the same issue.

Expected Behavior

When no results meet the relevance threshold, the system should return an empty result set gracefully without crashing.

Actual Behavior

When no results meet the relevance threshold, the system should return an empty result set gracefully without crashing.
The system crashes with the following error:

ValueError: not enough values to unpack (expected 3, got 0)
File "/app/backend/open_webui/retrieval/utils.py", line 191, in query_doc_with_hybrid_search
    distances, documents, metadatas = map(list, zip(*sorted_items))

Steps to Reproduce

Error Trace

2025-09-03 06:10:29.104 | ERROR | open_webui.retrieval.utils:process_query:381 - Error when querying the collection with hybrid_search: not enough values to unpack (expected 3, got 0)

> File "/app/backend/open_webui/retrieval/utils.py", line 368, in process_query
    result = query_doc_with_hybrid_search(...)

  File "/app/backend/open_webui/retrieval/utils.py", line 198, in query_doc_with_hybrid_search
    raise e

  File "/app/backend/open_webui/retrieval/utils.py", line 183, in query_doc_with_hybrid_search
    distances, documents, metadatas = map(list, zip(*sorted_items))

Logs & Screenshots

Error Trace

2025-09-03 06:10:29.104 | ERROR | open_webui.retrieval.utils:process_query:381 - Error when querying the collection with hybrid_search: not enough values to unpack (expected 3, got 0)

> File "/app/backend/open_webui/retrieval/utils.py", line 368, in process_query
    result = query_doc_with_hybrid_search(...)

  File "/app/backend/open_webui/retrieval/utils.py", line 198, in query_doc_with_hybrid_search
    raise e

  File "/app/backend/open_webui/retrieval/utils.py", line 183, in query_doc_with_hybrid_search
    distances, documents, metadatas = map(list, zip(*sorted_items))

Additional Information

Root Cause

In backend/open_webui/retrieval/utils.py, when the reranking process filters out all results (because none meet the r_score threshold), the sorted_items list becomes empty. The code then attempts to unpack this empty list into three variables, causing the crash:

# Line 191
distances, documents, metadatas = map(list, zip(*sorted_items))  # Crashes when sorted_items is []

Impact

  • Complete retrieval failure for queries with no highly relevant matches
  • System instability when strict reranking thresholds are used
  • No fallback mechanism for empty result scenarios
  • Poor user experience with error messages instead of graceful handling

Environment

  • Open WebUI version: main branch (latest)
  • Vector DB: All supported databases affected
  • Reranking: Enabled with strict r_score threshold

Suggested Fix

Add a safety check before unpacking to handle empty results:

if sorted_items:
    distances, documents, metadatas = map(list, zip(*sorted_items))
else:
    distances, documents, metadatas = [], [], []
Originally created by @hazemawadalla on GitHub (Oct 7, 2025). Original GitHub issue: https://github.com/open-webui/open-webui/issues/18096 ### Check Existing Issues - [x] I have searched for any existing and/or related issues. - [x] I have searched for any existing and/or related discussions. - [x] I am using the latest version of Open WebUI. ### Installation Method Git Clone ### Open WebUI Version 0.6.32 ### Ollama Version (if applicable) _No response_ ### Operating System Ubuntu 24.04 ### 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 **provided every relevant configuration, setting, and environment variable used in my setup.** - [x] I have clearly **listed every relevant configuration, custom setting, environment variable, and command-line option that influences my setup** (such as Docker Compose overrides, .env values, browser settings, authentication configurations, etc). - [x] I have documented **step-by-step reproduction instructions that are precise, sequential, and leave nothing to interpretation**. My steps: - Start with the initial platform/version/OS and dependencies used, - Specify exact install/launch/configure commands, - List URLs visited, user input (incl. example values/emails/passwords if needed), - Describe all options and toggles enabled or changed, - Include any files or environmental changes, - Identify the expected and actual result at each stage, - Ensure any reasonably skilled user can follow and hit the same issue. ### Expected Behavior When no results meet the relevance threshold, the system should return an empty result set gracefully without crashing. ### Actual Behavior When no results meet the relevance threshold, the system should return an empty result set gracefully without crashing. The system crashes with the following error: ``` ValueError: not enough values to unpack (expected 3, got 0) File "/app/backend/open_webui/retrieval/utils.py", line 191, in query_doc_with_hybrid_search distances, documents, metadatas = map(list, zip(*sorted_items)) ``` ### Steps to Reproduce ## Error Trace ``` 2025-09-03 06:10:29.104 | ERROR | open_webui.retrieval.utils:process_query:381 - Error when querying the collection with hybrid_search: not enough values to unpack (expected 3, got 0) > File "/app/backend/open_webui/retrieval/utils.py", line 368, in process_query result = query_doc_with_hybrid_search(...) File "/app/backend/open_webui/retrieval/utils.py", line 198, in query_doc_with_hybrid_search raise e File "/app/backend/open_webui/retrieval/utils.py", line 183, in query_doc_with_hybrid_search distances, documents, metadatas = map(list, zip(*sorted_items)) ``` ### Logs & Screenshots ## Error Trace ``` 2025-09-03 06:10:29.104 | ERROR | open_webui.retrieval.utils:process_query:381 - Error when querying the collection with hybrid_search: not enough values to unpack (expected 3, got 0) > File "/app/backend/open_webui/retrieval/utils.py", line 368, in process_query result = query_doc_with_hybrid_search(...) File "/app/backend/open_webui/retrieval/utils.py", line 198, in query_doc_with_hybrid_search raise e File "/app/backend/open_webui/retrieval/utils.py", line 183, in query_doc_with_hybrid_search distances, documents, metadatas = map(list, zip(*sorted_items)) ``` ### Additional Information ## Root Cause In `backend/open_webui/retrieval/utils.py`, when the reranking process filters out all results (because none meet the `r_score` threshold), the `sorted_items` list becomes empty. The code then attempts to unpack this empty list into three variables, causing the crash: ```python # Line 191 distances, documents, metadatas = map(list, zip(*sorted_items)) # Crashes when sorted_items is [] ``` ## Impact - Complete retrieval failure for queries with no highly relevant matches - System instability when strict reranking thresholds are used - No fallback mechanism for empty result scenarios - Poor user experience with error messages instead of graceful handling ## Environment - Open WebUI version: main branch (latest) - Vector DB: All supported databases affected - Reranking: Enabled with strict r_score threshold ## Suggested Fix Add a safety check before unpacking to handle empty results: ```python if sorted_items: distances, documents, metadatas = map(list, zip(*sorted_items)) else: distances, documents, metadatas = [], [], [] ```
GiteaMirror added the bug label 2026-05-25 09:47:15 -05:00
Author
Owner

@hazemawadalla commented on GitHub (Oct 7, 2025):

https://github.com/open-webui/open-webui/pull/18095#issue-3490003168

<!-- gh-comment-id:3375275308 --> @hazemawadalla commented on GitHub (Oct 7, 2025): https://github.com/open-webui/open-webui/pull/18095#issue-3490003168
Author
Owner

@tjbck commented on GitHub (Oct 7, 2025):

Addressed in dev.

<!-- gh-comment-id:3376679058 --> @tjbck commented on GitHub (Oct 7, 2025): Addressed in dev.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#138216