litellm/tests/guardrails_tests
yucheng-berri a06d63f99e
fix(logging): blocked requests no longer report guardrail_status=success in multi-guardrail configs (#39596)
* fix(logging): aggregate guardrail_status by severity across guardrail entries

A pre_call guardrail that passed (e.g. hide-secrets recording a mask)
appends its entry before a later guardrail's block, and the first-wins
reader reported the blocked request as guardrail_status=success in
StandardLoggingPayload.status_fields. Take the most severe status
across all entries instead: guardrail_intervened >
guardrail_failed_to_respond > success > not_run.

* refactor(logging): express guardrail status severity as an immutable order

Replace the precedence dict and rebinding loop with a severity-ordered
tuple and a max() aggregation, per the repo's no-mutation and
mutable-collection lint gates; parametrize the severity test cases.
No behavior change.

* style(logging): apply ruff format to entries binding
2026-09-03 17:33:31 -07:00
..
conftest.py
test_akto_guardrails.py
test_bedrock_guardrails.py
test_custom_guardrail.py
test_deepkeep_guardrails.py
test_dynamoai_guardrails.py
test_eu_ai_act_article5.py
test_eu_ai_act_french_3_scenarios.py
test_guardrail_load_balancing.py
test_guardrails_config.py
test_javelin_guardrails.py
test_lakera_v2.py
test_lasso_guardrails.py
test_presidio_pii.py
test_semantic_guard.py
test_sg_mas_ai_guardrails.py
test_sg_pdpa_guardrails.py
test_tracing_guardrails.py fix(logging): blocked requests no longer report guardrail_status=success in multi-guardrail configs (#39596) 2026-09-03 17:33:31 -07:00
test_zscaler_ai_guard.py