mirror of
https://github.com/BerriAI/litellm.git
synced 2026-12-03 01:38:46 +00:00
* test(e2e): move the Gemini Flash alias off the retired gemini-2.5-flash Google AI Studio now answers 404 for gemini-2.5-flash on new projects, so the e2e aliases move to gemini-3.8-flash. The Vertex alias and every Vertex deployment, batch, and passthrough URL use the global location, because gemini-3.8-flash is only served there 3.8 Flash thinks by default, so the Vertex chat tests send reasoning_effort none with more max_tokens, and the Presidio pre_call tests get the same 512 token room as post_call. The custom pricing override rates are scaled to stay about 100x above the new base price * test(e2e): keep the default Vertex chat request shape and fit 3.8 Flash thinking in the guardrail and cache tests * test(e2e): give the streamed Bedrock post_call test room for 3.8 Flash thinking * test(e2e): keep main's custom pricing override rates main already moved the custom pricing test to Gemini 3.8 Flash with its own rates, so the merge only needed to keep them * test(e2e): give the Vertex tool call test room for default thinking 3.8 Flash thinks by default, so the tool call test gets the same 1024 token cap as the other Vertex chat tests --------- Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com>
50 lines
1.9 KiB
Python
50 lines
1.9 KiB
Python
"""Live e2e: the per-request `guardrails` selector must fail closed.
|
|
|
|
A request that names a guardrail is a caller asking for protection. When the
|
|
proxy does not serve that name (a typo, a deleted guardrail, or a worker that
|
|
never loaded it), answering 200 silently drops the protection the caller asked
|
|
for; the contract this test pins is a 4xx naming the unknown guardrail.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import pytest
|
|
from e2e_config import unique_marker
|
|
from e2e_http import UnknownApiError, ValidationError
|
|
from e2e_metadata import Domain, Mode, Provider, Subject, meta
|
|
from guardrails_client import GuardrailsClient
|
|
|
|
pytestmark = pytest.mark.e2e
|
|
|
|
MODEL = "gemini-3.8-flash"
|
|
|
|
|
|
@pytest.mark.skip(
|
|
reason=(
|
|
"stage red: product gap, a request naming a guardrail the proxy does not "
|
|
"serve is silently served unguarded (200) instead of failing closed"
|
|
)
|
|
)
|
|
@pytest.mark.covers(
|
|
"guardrail.dispatch.pre_call.rejects_unknown_name",
|
|
exercised_on=["chat_completions"],
|
|
)
|
|
@meta(
|
|
Subject(
|
|
domain=Domain.GUARDRAILS,
|
|
providers=(Provider.GEMINI,),
|
|
models=(MODEL,),
|
|
mode=Mode.NONSTREAM,
|
|
)
|
|
)
|
|
def test_request_naming_an_unknown_guardrail_fails_closed(client: GuardrailsClient, scoped_key: str) -> None:
|
|
result = client.chat(scoped_key, MODEL, "say hi", guardrails=[f"e2e-no-such-guardrail-{unique_marker()}"])
|
|
|
|
match result:
|
|
case UnknownApiError(status_code=status, body=body):
|
|
assert status == 400, f"expected a 400 for an unknown guardrail name, got {status}: {body[:400]}"
|
|
assert "guardrail" in body.lower(), f"the rejection should name the guardrail; got: {body[:400]}"
|
|
case ValidationError(message=message):
|
|
assert "guardrail" in message.lower(), f"the rejection should name the guardrail; got: {message[:400]}"
|
|
case _:
|
|
pytest.fail(f"a request naming an unknown guardrail must fail closed with a 4xx; got {result}")
|