fix(guardrails): use plural key in get_disable_global_guardrail#25488
Conversation
Rename disable_global_guardrail → disable_global_guardrails to match the key name used by litellm_pre_call_utils.py, the API endpoints, and the UI when propagating key/team metadata. The singular form was introduced in PR BerriAI#16983 and has never matched the plural form written by the rest of the codebase, so the feature silently did nothing.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile SummaryThis PR fixes a longstanding bug where The test data is updated correctly to use the plural key, and the fix is well-scoped. Confidence Score: 5/5Safe to merge — the fix is correct and well-tested; remaining findings are cosmetic only. The core change is a straightforward key-name correction that aligns the consumer with every producer in the codebase, making a previously silent feature work correctly. All test data is updated to match. The only remaining findings are a stale method name and stale comments — both P2 style issues that do not affect correctness or behaviour. No files require special attention.
|
| Filename | Overview |
|---|---|
| litellm/integrations/custom_guardrail.py | Fixes singular→plural key mismatch in get_disable_global_guardrail(); method name itself retains the old singular form as a minor inconsistency. |
| tests/test_litellm/integrations/test_custom_guardrail.py | Test data updated to use plural key; test method name and inline comments still reference the old singular form, but this is cosmetic only. |
| tests/test_litellm/proxy/guardrails/guardrail_hooks/test_panw_prisma_airs.py | Single test parameter updated to use plural key disable_global_guardrails=True; straightforward and correct. |
Sequence Diagram
sequenceDiagram
participant UI as UI / API Endpoint
participant PreCall as litellm_pre_call_utils.py
participant Meta as request metadata
participant Guard as CustomGuardrail.get_disable_global_guardrail()
UI->>PreCall: key/team metadata with disable_global_guardrails=true
PreCall->>Meta: write data[metadata][disable_global_guardrails] = true
Meta->>Guard: check disable_global_guardrails in data / metadata
Guard-->>Guard: BEFORE - checked singular disable_global_guardrail, never matched
Guard-->>Guard: AFTER - checks plural disable_global_guardrails, matches correctly
Guard->>Guard: return True, skip guardrail
Comments Outside Diff (2)
-
litellm/integrations/custom_guardrail.py, line 258 (link)Method name retains old singular form
The method is named
get_disable_global_guardrail(singular) while its body now reads the plural keydisable_global_guardrails. The call site at line 408 (disable_global_guardrail = self.get_disable_global_guardrail(data)) also still uses the old name. Consider renaming both toget_disable_global_guardrailsto stay consistent with the key it reads and avoid future confusion. -
tests/test_litellm/integrations/test_custom_guardrail.py, line 175-176 (link)Stale singular references in test name/docstring
The method name and its docstring still say
disable_global_guardrail(singular) after the key was renamed to the plural form. The inline comments on lines 196, 207, 209, 220, 222, 233, 235, 246 have the same stale wording. Consider updating them all todisable_global_guardrailsfor consistency.
Reviews (1): Last reviewed commit: "fix(guardrails): use plural key in get_d..." | Re-trigger Greptile
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
this is a good bug fix, going to merge into my feature branch/staging |
13771a7
into
BerriAI:litellm_feat-per-guardrail-opt-out-for-global-guardrails
Rename disable_global_guardrail → disable_global_guardrails to match the key name used by litellm_pre_call_utils.py, the API endpoints, and the UI when propagating key/team metadata. The singular form was introduced in PR #16983 and has never matched the plural form written by the rest of the codebase, so the feature silently did nothing. Re-applies fix originally from #25488. Original commit could not be merged due to missing signature. Co-Authored-By: Remi Mabon <remi.mabon@redcare-pharmacy.com>
Rename disable_global_guardrail → disable_global_guardrails to match the key name used by litellm_pre_call_utils.py, the API endpoints, and the UI when propagating key/team metadata.
The singular form was introduced in PR #16983 and has never matched the plural form written by the rest of the codebase, so the feature silently did nothing.
Relevant issues
Fixes #25487
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
tests/test_litellm/directory, Adding at least 1 test is a hard requirement - see detailsmake test-unit@greptileaiand received a Confidence Score of at least 4/5 before requesting a maintainer reviewDelays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
CI (LiteLLM team)
Branch creation CI run
Link:
CI run for the last commit
Link:
Merge / cherry-pick CI run
Links:
Type
🐛 Bug Fix
Changes
get_disable_global_guardrail() in custom_guardrail.py checks for the key disable_global_guardrail (singular), but every producer — litellm_pre_call_utils.py (key and team metadata propagation), the
API endpoints, and the UI — writes disable_global_guardrails (plural). The keys never match, so setting disable_global_guardrails: true on an API key or team has no effect.
The mismatch was introduced in PR #16983 (2025-11-22) across two commits 10 minutes apart — the method used singular, the propagation used plural.
Fix: Rename disable_global_guardrail → disable_global_guardrails in the consumer method and update corresponding tests.
Files changed: