mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-07 07:58:09 +00:00
test(router): expect no fallback errors header for non-bool include_fallback_errors (#50259)
The Rust core reports fallback errors only when include_fallback_errors is literally true. The routing and SDK wire tests still expected the header for truthy non-bool values (1 and a 5 KB string), which the deleted Python core produced by accident. Every non-bool value now expects no errors, and the flag still must not reach the provider.
This commit is contained in:
parent
4a092f06f0
commit
300db9f01d
2 changed files with 18 additions and 22 deletions
|
|
@ -61,10 +61,10 @@ _PROVIDERS: Final = MappingProxyType(
|
|||
)
|
||||
_STREAMING: Final = (pytest.param(False, id="non-stream"), pytest.param(True, id="stream"))
|
||||
_NON_BOOLEAN_FLAGS: Final = (
|
||||
pytest.param(1, True, id="int"),
|
||||
pytest.param("", False, id="empty-string"),
|
||||
pytest.param([], False, id="list"),
|
||||
pytest.param("x" * 5120, True, id="five-kilobytes"),
|
||||
pytest.param(1, id="int"),
|
||||
pytest.param("", id="empty-string"),
|
||||
pytest.param([], id="list"),
|
||||
pytest.param("x" * 5120, id="five-kilobytes"),
|
||||
)
|
||||
_OPENAI_UNAUTHORIZED: Final = Reply(
|
||||
status=401,
|
||||
|
|
@ -326,10 +326,8 @@ def test_default_gateway_keeps_the_flag_off_the_wire_on_a_fallback(
|
|||
assert observed.attempted == "1", observed
|
||||
|
||||
|
||||
@pytest.mark.parametrize(("value", "errors_reported"), _NON_BOOLEAN_FLAGS)
|
||||
def test_default_gateway_keeps_a_non_boolean_flag_off_the_wire(
|
||||
registered: _Registered, value: JsonValue, errors_reported: bool
|
||||
) -> None:
|
||||
@pytest.mark.parametrize("value", _NON_BOOLEAN_FLAGS)
|
||||
def test_default_gateway_keeps_a_non_boolean_flag_off_the_wire(registered: _Registered, value: JsonValue) -> None:
|
||||
sent: Final = _send(
|
||||
registered.gateway,
|
||||
_PATHS["chat"],
|
||||
|
|
@ -497,9 +495,9 @@ def test_exposed_chat_without_a_fallback_keeps_the_flag_off_the_wire_and_the_err
|
|||
assert observed.errors_header is None, observed
|
||||
|
||||
|
||||
@pytest.mark.parametrize(("value", "errors_reported"), _NON_BOOLEAN_FLAGS)
|
||||
def test_exposed_chat_keeps_a_non_boolean_flag_off_the_wire_and_the_errors_header_follows_its_truthiness(
|
||||
exposed: _Exposed, value: JsonValue, errors_reported: bool
|
||||
@pytest.mark.parametrize("value", _NON_BOOLEAN_FLAGS)
|
||||
def test_exposed_chat_keeps_a_non_boolean_flag_off_the_wire_and_reports_no_errors(
|
||||
exposed: _Exposed, value: JsonValue
|
||||
) -> None:
|
||||
sent: Final = _send(
|
||||
exposed.proxy,
|
||||
|
|
@ -515,7 +513,7 @@ def test_exposed_chat_keeps_a_non_boolean_flag_off_the_wire_and_the_errors_heade
|
|||
assert observed.leaks == (), observed
|
||||
assert observed.hit == (_EXPOSED_OPENAI_PRIMARY, _EXPOSED_OPENAI_BACKUP), observed
|
||||
assert observed.attempted == "1", observed
|
||||
assert _errors_mention_the_outage(observed.errors_header) is errors_reported, observed
|
||||
assert observed.errors_header is None, observed
|
||||
|
||||
|
||||
def test_exposed_proxy_rejects_an_unauthenticated_flagged_request_before_the_wire(exposed: _Exposed) -> None:
|
||||
|
|
|
|||
|
|
@ -36,11 +36,11 @@ _BURST: Final = 12
|
|||
_CALLBACK_WINDOW: Final = 15.0
|
||||
_STREAMING: Final = (pytest.param(False, id="non-stream"), pytest.param(True, id="stream"))
|
||||
_NON_BOOLEAN_FLAGS: Final = (
|
||||
pytest.param(1, True, id="int"),
|
||||
pytest.param("", False, id="empty-string"),
|
||||
pytest.param([], False, id="list"),
|
||||
pytest.param("x" * 5120, True, id="five-kilobytes"),
|
||||
pytest.param(False, False, id="false"),
|
||||
pytest.param(1, id="int"),
|
||||
pytest.param("", id="empty-string"),
|
||||
pytest.param([], id="list"),
|
||||
pytest.param("x" * 5120, id="five-kilobytes"),
|
||||
pytest.param(False, id="false"),
|
||||
)
|
||||
_UNAUTHORIZED: Final = Reply(
|
||||
status=401,
|
||||
|
|
@ -263,10 +263,8 @@ def test_without_a_fallback_the_flag_still_stays_off_the_wire() -> None:
|
|||
assert outcome.errors == (), outcome
|
||||
|
||||
|
||||
@pytest.mark.parametrize(("value", "errors_reported"), _NON_BOOLEAN_FLAGS)
|
||||
def test_a_non_boolean_flag_stays_off_the_wire_and_the_errors_header_follows_its_truthiness(
|
||||
value: object, errors_reported: bool
|
||||
) -> None:
|
||||
@pytest.mark.parametrize("value", _NON_BOOLEAN_FLAGS)
|
||||
def test_a_flag_other_than_true_stays_off_the_wire_and_reports_no_errors(value: object) -> None:
|
||||
with wire_server(_peer) as wire:
|
||||
router: Final = _router(wire)
|
||||
outcome: Final = _outcome(wire, _complete(router, "primary", stream=False, include_fallback_errors=value))
|
||||
|
|
@ -274,7 +272,7 @@ def test_a_non_boolean_flag_stays_off_the_wire_and_the_errors_header_follows_its
|
|||
assert outcome.hit == ("primary", "backup"), outcome
|
||||
assert outcome.text == f"{_ANSWER} backup", outcome
|
||||
assert outcome.attempted == 1, outcome
|
||||
assert (len(outcome.errors) == 1) is errors_reported, outcome
|
||||
assert outcome.errors == (), outcome
|
||||
|
||||
|
||||
class _Recorder(CustomLogger):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue