[PR #21210] [CLOSED] fix: use keyword args for IndicesClient.refresh() (opensearch-py >= 3.0.0) #41599

Closed
opened 2026-04-25 13:46:48 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/21210
Author: @veeceey
Created: 2/6/2026
Status: Closed

Base: devHead: fix/issue-20649-opensearch-refresh-kwarg


📝 Commits (1)

  • 108b6cf fix: use keyword args for IndicesClient.refresh() (opensearch-py >= 3.0.0)

📊 Changes

2 files changed (+345 additions, -3 deletions)

View changed files

📝 backend/open_webui/retrieval/vector/dbs/opensearch.py (+3 -3)
backend/open_webui/test/apps/webui/routers/test_opensearch.py (+342 -0)

📄 Description

Description

Fixes #20649

In opensearch-py >= 3.0.0, all auto-generated API methods switched to keyword-only arguments. The three calls to IndicesClient.refresh() in the OpenSearch vector DB client were passing the index name as a positional argument, causing:

TypeError: IndicesClient.refresh() takes 1 positional argument but 2
positional arguments (and 2 keyword-only arguments) were given

This made it impossible to add documents to a knowledge base when using OpenSearch as the vector DB backend.

Changed

  • backend/open_webui/retrieval/vector/dbs/opensearch.py: Changed all 3 refresh() call sites from positional to keyword argument (index=)

Fixed

  • Fixed TypeError crash when using OpenSearch as vector DB backend with opensearch-py >= 3.0.0
  • Affected methods: insert(), upsert(), delete()
  • Using index= keyword arg is backward-compatible with opensearch-py < 3.0.0

Testing

I have personally tested all changes:

  1. Wrote 9 unit tests that mock the opensearch-py 3.0.0 keyword-only signature enforcement
  2. All 9 tests pass with the fix applied:
$ python3 -m pytest backend/open_webui/test/apps/webui/routers/test_opensearch.py -v

test_insert_calls_refresh_with_keyword_arg PASSED
test_upsert_calls_refresh_with_keyword_arg PASSED
test_delete_by_ids_calls_refresh_with_keyword_arg PASSED
test_delete_by_filter_calls_refresh_with_keyword_arg PASSED
test_refresh_raises_typeerror_with_positional_arg_on_3x PASSED
test_has_collection_uses_keyword_args PASSED
test_delete_collection_uses_keyword_args PASSED
test_search_uses_keyword_args PASSED
test_reset_uses_keyword_args PASSED

9 passed in 0.03s
  1. Verified the tests correctly FAIL on unfixed code by temporarily reverting the change
  2. Audited all other opensearch-py API calls in the file - they already use keyword arguments

Changelog Entry

Fixed

  • Fixed TypeError crash when adding documents to knowledge base with OpenSearch backend and opensearch-py >= 3.0.0 by using keyword arguments for IndicesClient.refresh() (#20649)

Contributor License Agreement

By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.


🔄 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/21210 **Author:** [@veeceey](https://github.com/veeceey) **Created:** 2/6/2026 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `fix/issue-20649-opensearch-refresh-kwarg` --- ### 📝 Commits (1) - [`108b6cf`](https://github.com/open-webui/open-webui/commit/108b6cf6b385a1a1951f641e78435629da989bf9) fix: use keyword args for IndicesClient.refresh() (opensearch-py >= 3.0.0) ### 📊 Changes **2 files changed** (+345 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/retrieval/vector/dbs/opensearch.py` (+3 -3) ➕ `backend/open_webui/test/apps/webui/routers/test_opensearch.py` (+342 -0) </details> ### 📄 Description ### Description Fixes #20649 In `opensearch-py >= 3.0.0`, all auto-generated API methods switched to keyword-only arguments. The three calls to `IndicesClient.refresh()` in the OpenSearch vector DB client were passing the index name as a positional argument, causing: ``` TypeError: IndicesClient.refresh() takes 1 positional argument but 2 positional arguments (and 2 keyword-only arguments) were given ``` This made it impossible to add documents to a knowledge base when using OpenSearch as the vector DB backend. ### Changed - `backend/open_webui/retrieval/vector/dbs/opensearch.py`: Changed all 3 `refresh()` call sites from positional to keyword argument (`index=`) ### Fixed - Fixed `TypeError` crash when using OpenSearch as vector DB backend with `opensearch-py >= 3.0.0` - Affected methods: `insert()`, `upsert()`, `delete()` - Using `index=` keyword arg is backward-compatible with `opensearch-py < 3.0.0` ### Testing I have personally tested all changes: 1. Wrote 9 unit tests that mock the opensearch-py 3.0.0 keyword-only signature enforcement 2. All 9 tests pass with the fix applied: ``` $ python3 -m pytest backend/open_webui/test/apps/webui/routers/test_opensearch.py -v test_insert_calls_refresh_with_keyword_arg PASSED test_upsert_calls_refresh_with_keyword_arg PASSED test_delete_by_ids_calls_refresh_with_keyword_arg PASSED test_delete_by_filter_calls_refresh_with_keyword_arg PASSED test_refresh_raises_typeerror_with_positional_arg_on_3x PASSED test_has_collection_uses_keyword_args PASSED test_delete_collection_uses_keyword_args PASSED test_search_uses_keyword_args PASSED test_reset_uses_keyword_args PASSED 9 passed in 0.03s ``` 3. Verified the tests correctly FAIL on unfixed code by temporarily reverting the change 4. Audited all other opensearch-py API calls in the file - they already use keyword arguments ### Changelog Entry #### Fixed - Fixed `TypeError` crash when adding documents to knowledge base with OpenSearch backend and `opensearch-py >= 3.0.0` by using keyword arguments for `IndicesClient.refresh()` (#20649) ### Contributor License Agreement By submitting this pull request, I confirm that I have read and fully agree to the [Contributor License Agreement (CLA)](https://github.com/open-webui/open-webui/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT), and I am providing my contributions under its terms. --- <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-25 13:46:48 -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#41599