Skip to content

fix(guardrails): use plural key in get_disable_global_guardrail#25488

Merged
ryan-crabbe-berri merged 1 commit intoBerriAI:litellm_feat-per-guardrail-opt-out-for-global-guardrailsfrom
rmabon:fix/disable-global-guardrails-plural-key
Apr 11, 2026
Merged

fix(guardrails): use plural key in get_disable_global_guardrail#25488
ryan-crabbe-berri merged 1 commit intoBerriAI:litellm_feat-per-guardrail-opt-out-for-global-guardrailsfrom
rmabon:fix/disable-global-guardrails-plural-key

Conversation

@rmabon
Copy link
Copy Markdown
Contributor

@rmabon rmabon commented Apr 10, 2026

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

  • I have Added testing in the tests/test_litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem
  • I have requested a Greptile review by commenting @greptileai and received a Confidence Score of at least 4/5 before requesting a maintainer review

Delays 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)

CI status guideline:

  • 50-55 passing tests: main is stable with minor issues.
  • 45-49 passing tests: acceptable but needs attention
  • <= 40 passing tests: unstable; be careful with your merges and assess the risk.
  • 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:

  • litellm/integrations/custom_guardrail.py — 4 lines: singular → plural in get_disable_global_guardrail()
  • tests/test_litellm/integrations/test_custom_guardrail.py — 4 lines: update test data to use plural key
  • tests/test_litellm/proxy/guardrails/guardrail_hooks/test_panw_prisma_airs.py — 1 line: update test param to use plural key

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.
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 10, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
litellm Ready Ready Preview, Comment Apr 10, 2026 11:37am

Request Review

@rmabon
Copy link
Copy Markdown
Contributor Author

rmabon commented Apr 10, 2026

@greptileai

@codspeed-hq
Copy link
Copy Markdown
Contributor

codspeed-hq bot commented Apr 10, 2026

Merging this PR will not alter performance

✅ 16 untouched benchmarks


Comparing rmabon:fix/disable-global-guardrails-plural-key (7970846) with main (9e6d2d2)

Open in CodSpeed

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 10, 2026

Greptile Summary

This PR fixes a longstanding bug where get_disable_global_guardrail() in custom_guardrail.py was checking for the key disable_global_guardrail (singular), while every producer — litellm_pre_call_utils.py, the management API endpoints, and the UI — writes disable_global_guardrails (plural). The fix correctly updates the consumer to match the plural key, making the feature functional for the first time since its introduction in PR #16983.

The test data is updated correctly to use the plural key, and the fix is well-scoped.

Confidence Score: 5/5

Safe 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.

Important Files Changed

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
Loading

Comments Outside Diff (2)

  1. litellm/integrations/custom_guardrail.py, line 258 (link)

    P2 Method name retains old singular form

    The method is named get_disable_global_guardrail (singular) while its body now reads the plural key disable_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 to get_disable_global_guardrails to stay consistent with the key it reads and avoid future confusion.

  2. tests/test_litellm/integrations/test_custom_guardrail.py, line 175-176 (link)

    P2 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 to disable_global_guardrails for consistency.

Reviews (1): Last reviewed commit: "fix(guardrails): use plural key in get_d..." | Re-trigger Greptile

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@ryan-crabbe-berri
Copy link
Copy Markdown
Collaborator

this is a good bug fix, going to merge into my feature branch/staging

@ryan-crabbe-berri ryan-crabbe-berri changed the base branch from main to litellm_feat-per-guardrail-opt-out-for-global-guardrails April 11, 2026 18:54
@ryan-crabbe-berri ryan-crabbe-berri merged commit 13771a7 into BerriAI:litellm_feat-per-guardrail-opt-out-for-global-guardrails Apr 11, 2026
49 of 51 checks passed
ryan-crabbe-berri added a commit that referenced this pull request Apr 12, 2026
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: disable_global_guardrails per key/team has no effect (singular/plural key mismatch)

2 participants