fix(vector_stores): refuse a caller index on slash-form OpenSearch stores

This commit is contained in:
mateo-berri 2026-10-29 07:36:09 -07:00
parent 5a83e009b3
commit cc583a1ce0
3 changed files with 5 additions and 3 deletions

View file

@ -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(

View file

@ -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

View file

@ -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