fix: handle provider_config type error in passthrough error handler (#12101)

- Fix type error where _handle_error was called with provider_config=None
- Add proper provider config retrieval logic similar to llm_passthrough_route
- Handle cases where provider config may not be available
- Ensure type safety while maintaining backward compatibility
This commit is contained in:
Cole McIntosh 2025-06-27 10:11:28 -06:00 committed by GitHub
parent e3c9318bd4
commit a56c28ab2f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -86,9 +86,39 @@ async def allm_passthrough_route(
response = init_response
return response
except Exception as e:
# For passthrough routes, we need to get the provider config to properly handle errors
from litellm.types.utils import LlmProviders
from litellm.utils import ProviderConfigManager
# Get the provider using the same logic as llm_passthrough_route
_, resolved_custom_llm_provider, _, _ = get_llm_provider(
model=model,
custom_llm_provider=custom_llm_provider,
api_base=api_base,
api_key=api_key,
)
# Get provider config if available
provider_config = None
if resolved_custom_llm_provider:
try:
provider_config = cast(
Optional["BasePassthroughConfig"], kwargs.get("provider_config")
) or ProviderConfigManager.get_provider_passthrough_config(
provider=LlmProviders(resolved_custom_llm_provider),
model=model,
)
except Exception:
# If we can't get provider config, pass None
pass
if provider_config is None:
# If no provider config available, raise the original exception
raise e
raise base_llm_http_handler._handle_error(
e=e,
provider_config=None,
provider_config=provider_config,
)