mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-16 09:22:22 +00:00
fix(vector_stores): refuse a caller index on slash-form OpenSearch stores
This commit is contained in:
parent
5a83e009b3
commit
cc583a1ce0
3 changed files with 5 additions and 3 deletions
|
|
@ -57,8 +57,10 @@ def reject_caller_embedding_selection_params(payload: Mapping[str, object], sour
|
|||
def reject_caller_opensearch_index_name(
|
||||
caller_body: Mapping[str, object], request_fields: Mapping[str, object], source: str
|
||||
) -> None:
|
||||
provider: Final = request_fields.get("custom_llm_provider")
|
||||
if (
|
||||
request_fields.get("custom_llm_provider") == LlmProviders.OPENSEARCH.value
|
||||
isinstance(provider, str)
|
||||
and provider.split("/", 1)[0] == LlmProviders.OPENSEARCH.value
|
||||
and "opensearch_index_name" in caller_body
|
||||
):
|
||||
raise HTTPException(
|
||||
|
|
|
|||
|
|
@ -1673,7 +1673,7 @@ def test_rag_query_rejects_caller_embedding_selection_params(client_internal_use
|
|||
|
||||
@pytest.mark.parametrize(
|
||||
("provider", "expected_status", "expected_searches"),
|
||||
[("opensearch", 400, 0), ("openai", 200, 1)],
|
||||
[("opensearch", 400, 0), ("opensearch/x", 400, 0), ("openai", 200, 1)],
|
||||
)
|
||||
def test_rag_query_rejects_caller_opensearch_index_name_only_on_opensearch_stores(
|
||||
client_internal_user, provider, expected_status, expected_searches
|
||||
|
|
|
|||
|
|
@ -3068,7 +3068,7 @@ def test_vector_store_search_rejects_caller_embedding_selection_params(blocked_k
|
|||
|
||||
@pytest.mark.parametrize(
|
||||
("provider", "expected_status", "expected_searches"),
|
||||
[("opensearch", 400, 0), ("openai", 200, 1)],
|
||||
[("opensearch", 400, 0), ("opensearch/x", 400, 0), ("openai", 200, 1)],
|
||||
)
|
||||
def test_vector_store_search_rejects_caller_opensearch_index_name_only_on_opensearch_stores(
|
||||
provider, expected_status, expected_searches
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue