[GH-ISSUE #22664] Bug: UnboundLocalError in oracle23ai.py get() method crashes hybrid search #35309

Closed
opened 2026-04-25 09:32:42 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @mango766 on GitHub (Mar 14, 2026).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/22664

Description

Hi there! I came across an UnboundLocalError in backend/open_webui/retrieval/vector/dbs/oracle23ai.py that causes hybrid search to crash when Oracle 23ai is configured as the vector database.

Root cause

In the get() method (around line 713-718), the limit variable is referenced in a log.info() call before it is assigned:

def get(self, collection_name: str) -> Optional[GetResult]:
    log.info(
        f"Getting items from collection '{collection_name}' with limit {limit}."  # <-- limit not defined yet
    )

    try:
        limit = 1000  # Hardcoded limit for get operation

Python raises UnboundLocalError: cannot access local variable 'limit' where it is not associated with a value because the assignment on line 718 causes Python to treat limit as a local variable throughout the entire function scope, even before the assignment executes.

Impact

This bug is triggered whenever VECTOR_DB_CLIENT.get(collection_name) is called on an Oracle23ai backend. The primary trigger path is:

  1. User enables Hybrid Search in Admin Panel > Settings > Document
  2. User uploads a document and performs a RAG query
  3. query_collection_with_hybrid_search() in retrieval/utils.py calls VECTOR_DB_CLIENT.get(collection_name) (line 502)
  4. The Oracle23ai get() method crashes with UnboundLocalError before any database query executes

This makes hybrid search completely unusable with Oracle 23ai.

Fix

Move the limit = 1000 assignment before the log.info() call so the variable is defined when it is first referenced. I will submit a PR shortly.

Environment

  • Open WebUI v0.8.8+ (verified present in current main)
  • Vector DB: Oracle 23ai
  • Hybrid Search: enabled

This is the same issue reported in #22616 and previously in #18356.

Originally created by @mango766 on GitHub (Mar 14, 2026). Original GitHub issue: https://github.com/open-webui/open-webui/issues/22664 ### Description Hi there! I came across an `UnboundLocalError` in `backend/open_webui/retrieval/vector/dbs/oracle23ai.py` that causes hybrid search to crash when Oracle 23ai is configured as the vector database. ### Root cause In the `get()` method (around line 713-718), the `limit` variable is referenced in a `log.info()` call **before** it is assigned: ```python def get(self, collection_name: str) -> Optional[GetResult]: log.info( f"Getting items from collection '{collection_name}' with limit {limit}." # <-- limit not defined yet ) try: limit = 1000 # Hardcoded limit for get operation ``` Python raises `UnboundLocalError: cannot access local variable 'limit' where it is not associated with a value` because the assignment on line 718 causes Python to treat `limit` as a local variable throughout the entire function scope, even before the assignment executes. ### Impact This bug is triggered whenever `VECTOR_DB_CLIENT.get(collection_name)` is called on an Oracle23ai backend. The primary trigger path is: 1. User enables **Hybrid Search** in Admin Panel > Settings > Document 2. User uploads a document and performs a RAG query 3. `query_collection_with_hybrid_search()` in `retrieval/utils.py` calls `VECTOR_DB_CLIENT.get(collection_name)` (line 502) 4. The Oracle23ai `get()` method crashes with `UnboundLocalError` before any database query executes This makes hybrid search completely unusable with Oracle 23ai. ### Fix Move the `limit = 1000` assignment before the `log.info()` call so the variable is defined when it is first referenced. I will submit a PR shortly. ### Environment - Open WebUI v0.8.8+ (verified present in current `main`) - Vector DB: Oracle 23ai - Hybrid Search: enabled ### Related This is the same issue reported in #22616 and previously in #18356.
GiteaMirror added the bug label 2026-04-25 09:32:42 -05:00
Author
Owner

@silentoplayz commented on GitHub (Mar 16, 2026):

Related (based on issue title) - https://github.com/open-webui/open-webui/issues/22616

<!-- gh-comment-id:4064733733 --> @silentoplayz commented on GitHub (Mar 16, 2026): Related (based on issue title) - https://github.com/open-webui/open-webui/issues/22616
Author
Owner

@Classic298 commented on GitHub (Mar 17, 2026):

fcf7208352

<!-- gh-comment-id:4078545496 --> @Classic298 commented on GitHub (Mar 17, 2026): https://github.com/open-webui/open-webui/commit/fcf720835285a4cea10fc1ebed0b454971463b20
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#35309