mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-13 23:11:40 +00:00
fix(vector_stores): refuse MongoDB vector store create with a 400, not a 500
litellm.exception_type passes only litellm's own exception types through untouched, so the NotImplementedError the search-only refusal raised reached the caller as APIConnectionError. The proxy served that as a 500 with a traceback in the body for what is a plain client mistake. Raising BadRequestError gives the caller a 400 and the message on its own.
This commit is contained in:
parent
32b501bf74
commit
ed8203757a
2 changed files with 16 additions and 4 deletions
|
|
@ -425,7 +425,7 @@ class MongoDBVectorStoreConfig(BaseDirectVectorStoreConfig):
|
|||
vector_store_create_optional_params: VectorStoreCreateOptionalRequestParams,
|
||||
api_base: str,
|
||||
) -> NoReturn:
|
||||
raise NotImplementedError(_SEARCH_ONLY_MESSAGE)
|
||||
raise config_error(_SEARCH_ONLY_MESSAGE)
|
||||
|
||||
def transform_create_vector_store_response(self, response: httpx.Response) -> NoReturn:
|
||||
raise NotImplementedError(_SEARCH_ONLY_MESSAGE)
|
||||
raise config_error(_SEARCH_ONLY_MESSAGE)
|
||||
|
|
|
|||
|
|
@ -515,15 +515,27 @@ def test_validation_runs_before_any_connection_is_opened():
|
|||
|
||||
|
||||
def test_create_vector_store_is_not_supported_and_says_why():
|
||||
"""litellm.exception_type only passes its own exception types through untouched, so a
|
||||
NotImplementedError here reaches the caller as APIConnectionError, which the proxy serves
|
||||
as a 500 with a traceback. Refusing an unsupported operation is a client error."""
|
||||
config = MongoDBVectorStoreConfig()
|
||||
|
||||
with pytest.raises(NotImplementedError, match="search-only"):
|
||||
with pytest.raises(BadRequestError, match="search-only"):
|
||||
config.transform_create_vector_store_request({}, "https://example.test")
|
||||
|
||||
with pytest.raises(NotImplementedError, match="search-only"):
|
||||
with pytest.raises(BadRequestError, match="search-only"):
|
||||
config.transform_create_vector_store_response(httpx.Response(200))
|
||||
|
||||
|
||||
def test_the_create_refusal_survives_the_public_sdk_error_wrapper():
|
||||
import litellm
|
||||
|
||||
with pytest.raises(BadRequestError) as raised:
|
||||
litellm.vector_stores.create(custom_llm_provider="mongodb", name="anything")
|
||||
|
||||
assert "search-only" in str(raised.value)
|
||||
|
||||
|
||||
def test_provider_config_manager_returns_the_mongodb_config():
|
||||
config = ProviderConfigManager.get_provider_vector_stores_config(LlmProviders.MONGODB)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue