mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-26 01:12:21 +00:00
test(errors): cover bug report link on unmapped SDK exceptions
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
2ab2cdd87a
commit
6f5286b48e
2 changed files with 30 additions and 1 deletions
|
|
@ -2462,7 +2462,7 @@ def exception_type(
|
|||
or custom_llm_provider in litellm.openai_compatible_providers
|
||||
or custom_llm_provider == "mistral"
|
||||
or custom_llm_provider == "runwayml"
|
||||
):
|
||||
) and (hasattr(original_exception, "request") or hasattr(original_exception, "status_code")):
|
||||
_map_openai_exception(
|
||||
model=model,
|
||||
original_exception=mappable_exception,
|
||||
|
|
|
|||
|
|
@ -972,6 +972,35 @@ def test_an_unmapped_exception_with_no_model_or_provider_is_a_connection_error(q
|
|||
assert "boom" in raised.value.message
|
||||
|
||||
|
||||
def test_unmapped_sdk_exception_includes_bug_report_link(quiet_exception_mapping):
|
||||
with pytest.raises(litellm.APIConnectionError) as raised:
|
||||
exception_type(
|
||||
model="gpt-4o",
|
||||
custom_llm_provider="openai",
|
||||
original_exception=ValueError("boom"),
|
||||
completion_kwargs={},
|
||||
extra_kwargs={},
|
||||
)
|
||||
|
||||
assert "https://github.com/BerriAI/litellm/issues/new?" in str(raised.value)
|
||||
assert "ValueError" in str(raised.value)
|
||||
|
||||
|
||||
def test_unmapped_sdk_exception_bug_report_link_can_be_disabled(quiet_exception_mapping, monkeypatch):
|
||||
monkeypatch.setenv("LITELLM_DISABLE_BUG_REPORT_LINK", "true")
|
||||
|
||||
with pytest.raises(litellm.APIConnectionError) as raised:
|
||||
exception_type(
|
||||
model="gpt-4o",
|
||||
custom_llm_provider="openai",
|
||||
original_exception=ValueError("boom"),
|
||||
completion_kwargs={},
|
||||
extra_kwargs={},
|
||||
)
|
||||
|
||||
assert "https://github.com/BerriAI/litellm/issues/new?" not in str(raised.value)
|
||||
|
||||
|
||||
def _raise_and_map(model: str | None, original_exception: Exception, custom_llm_provider: str | None) -> None:
|
||||
"""Calls exception_type() from inside the except block, as litellm/main.py does,
|
||||
so traceback.format_exc() has a real stack."""
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue