enhance AktoGuardrail error handling and update test initialization comments

This commit is contained in:
rzeta-10 2026-03-24 01:39:31 +05:30
parent 61fa049f7b
commit d9c761d31b
3 changed files with 4 additions and 1 deletions

View file

@ -12,6 +12,7 @@ if TYPE_CHECKING:
def initialize_guardrail(litellm_params: "LitellmParams", guardrail: "Guardrail"):
import litellm
# Note: AktoGuardrail only supports pre_call.
_akto_callback = AktoGuardrail(
akto_base_url=getattr(litellm_params, "akto_base_url", None),
akto_api_key=getattr(litellm_params, "akto_api_key", None),

View file

@ -114,7 +114,8 @@ class AktoGuardrail(CustomGuardrail):
},
timeout=self.guardrail_timeout,
)
except Exception as e:
except (httpx.RequestError, httpx.HTTPStatusError) as e:
# Fire-and-forget: log but never crash the request path
verbose_proxy_logger.error("Akto blocked-request ingest error: %s", e)
# ── Payload builders ──

View file

@ -135,6 +135,7 @@ def test_init_from_env():
def test_init_defaults():
# patch.dict restores popped keys on exit
with patch.dict(os.environ, {}, clear=False):
os.environ.pop("AKTO_ACCOUNT_ID", None)
os.environ.pop("AKTO_VXLAN_ID", None)