[PR #19023] [CLOSED] Fix hybrid search reranking 17046 #48111

Closed
opened 2026-04-29 23:38:28 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/19023
Author: @krishna-medapati
Created: 11/7/2025
Status: Closed

Base: mainHead: fix-hybrid-search-reranking-17046


📝 Commits (2)

  • 8083299 docs: add web loaders documentation and usage guide
  • 39f7427 fix: Handle AttributeError in hybrid search with reranking (#17046)

📊 Changes

2 files changed (+48 additions, -1 deletions)

View changed files

📝 backend/open_webui/retrieval/utils.py (+9 -1)
docs/web-loaders.md (+39 -0)

📄 Description

Description

Fixes #17046 - AttributeError when using hybrid search with reranking enabled.

Problem

The current code attempts to access collection_result.documents in the conditional check even after using hasattr(). Due to Python's short-circuit evaluation behavior, when collection_result is a list or doesn't have the documents attribute, the subsequent conditions still try to access .documents, causing an AttributeError.

Solution

Split the attribute existence checks from the content validation checks:

  1. First verify that both documents and metadatas attributes exist
  2. Then separately validate the document content in a second conditional block

Changes

  • Added separate conditional blocks for attribute existence checks vs content validation
  • Added hasattr() check for metadatas attribute (was missing)
  • Prevents AttributeError while maintaining all original validation logic
  • Added clarifying comments to explain the two-stage validation

Testing

  • Code compiles without syntax errors
  • Resolves the AttributeError described in issue #17046
  • Maintains all original validation behavior

Impact

This fix ensures that hybrid search with reranking works correctly without throwing AttributeError when the collection result doesn't have the expected structure.


By submitting this pull request, I confirm that my contribution is made under the terms of the contributor license agreement.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/19023 **Author:** [@krishna-medapati](https://github.com/krishna-medapati) **Created:** 11/7/2025 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix-hybrid-search-reranking-17046` --- ### 📝 Commits (2) - [`8083299`](https://github.com/open-webui/open-webui/commit/8083299c5050cb4d7ac9dfa72ead88410ad27186) docs: add web loaders documentation and usage guide - [`39f7427`](https://github.com/open-webui/open-webui/commit/39f7427af45baa5e4897b4cdb076bd4b4885024d) fix: Handle AttributeError in hybrid search with reranking (#17046) ### 📊 Changes **2 files changed** (+48 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/retrieval/utils.py` (+9 -1) ➕ `docs/web-loaders.md` (+39 -0) </details> ### 📄 Description ## Description Fixes #17046 - AttributeError when using hybrid search with reranking enabled. ## Problem The current code attempts to access `collection_result.documents` in the conditional check even after using `hasattr()`. Due to Python's short-circuit evaluation behavior, when `collection_result` is a list or doesn't have the `documents` attribute, the subsequent conditions still try to access `.documents`, causing an `AttributeError`. ## Solution Split the attribute existence checks from the content validation checks: 1. First verify that both `documents` and `metadatas` attributes exist 2. Then separately validate the document content in a second conditional block ## Changes - Added separate conditional blocks for attribute existence checks vs content validation - Added `hasattr()` check for `metadatas` attribute (was missing) - Prevents `AttributeError` while maintaining all original validation logic - Added clarifying comments to explain the two-stage validation ## Testing - [x] Code compiles without syntax errors - [x] Resolves the AttributeError described in issue #17046 - [x] Maintains all original validation behavior ## Impact This fix ensures that hybrid search with reranking works correctly without throwing `AttributeError` when the collection result doesn't have the expected structure. --- By submitting this pull request, I confirm that my contribution is made under the terms of the contributor license agreement. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-29 23:38:28 -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#48111