From 12ebe8bebc1ba3e7c71640590f1f30cb3a0b16f1 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Wed, 20 May 2026 23:19:42 +0000 Subject: [PATCH] fix(rubrik): apply event_hook default when caller passes None initialize_guardrail always passes event_hook=litellm_params.mode, so setdefault never applied its default. When mode is omitted from the guardrail config, event_hook ended up as None instead of post_call. Use 'or' to fall back to the intended default when the value is None. Co-authored-by: Yassin Kortam --- litellm/integrations/rubrik.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/litellm/integrations/rubrik.py b/litellm/integrations/rubrik.py index 5a4e020e8b1..5fe0edd2fa0 100644 --- a/litellm/integrations/rubrik.py +++ b/litellm/integrations/rubrik.py @@ -48,7 +48,10 @@ class RubrikLogger(CustomGuardrail, CustomBatchLogger): ): self.flush_lock = asyncio.Lock() kwargs.setdefault("guardrail_name", "rubrik") - kwargs.setdefault("event_hook", GuardrailEventHooks.post_call) + # Use `or` rather than setdefault because callers (e.g. + # initialize_guardrail) always pass event_hook explicitly, possibly as + # None when the user omits `mode` from the guardrail config. + kwargs["event_hook"] = kwargs.get("event_hook") or GuardrailEventHooks.post_call kwargs.setdefault("default_on", True) super().__init__( flush_lock=self.flush_lock,