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 <yassin@berri.ai>
This commit is contained in:
Cursor Agent 2026-05-20 23:19:42 +00:00
parent 8f4c4630d3
commit 12ebe8bebc
No known key found for this signature in database

View file

@ -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,