* fix(ui/): add mcp input as an example for custom code guardrails
* feat(a2a/): ensure a2a guardrails works on response output
* feat(a2a/): support streaming guardrails
* fix(ui/): add mcp input as an example for custom code guardrails
The __init__ method was trying to access self.__annotations__ before
super().__init__() was called, resulting in an empty annotations dict.
Changed to use the class annotations directly: LiteLLM_JWTAuth.__annotations__
instead of self.__annotations__.
This fixes the ValueError:
"Invalid arguments provided: user_email_jwt_field, user_id_upsert,
user_allowed_email_domain. Allowed arguments are: ."
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Fixes issue where users with disallowed email domains receive a
generic "user doesn't exist" error instead of a clear message
about the email domain not being allowed.
Changes:
- Add explicit check for valid_user_email before get_user_object
- Raise ProxyException with clear error message when email domain
is not in the allowed list
- Prevents confusing error message for email domain restrictions
This fixes the test_allow_access_by_email test failure.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Fixes PLR0915 linting error (too many statements: 64 > 50) by extracting
repeated logic into four helper methods:
- _handle_conditional_match
- _handle_category_keyword_match
- _handle_pattern_match
- _handle_blocked_word_match
This improves code organization and maintainability while preserving
all existing functionality.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Restructure comments to make the intent clearer:
- First function: matches/tracks policies (may find nothing)
- Second function: always runs independent resolution (may find inherited guardrails)
This makes it clear why both functions must always be called.
Remove early return when applied_policy_names is empty to preserve
original behavior where PolicyResolver.resolve_guardrails_for_context()
is always called. The resolver does its own independent matching and
inheritance resolution, which can apply guardrails from parent policies
even when child policies fail their conditions.
This ensures no guardrails are silently dropped due to the refactoring.
Addresses Greptile review feedback on behavioral change.
Add PolicyMatchContext to TYPE_CHECKING block to fix F821 undefined
name errors in helper function type hints.
Fixes:
- proxy/litellm_pre_call_utils.py:1524:15: F821
- proxy/litellm_pre_call_utils.py:1596:15: F821
Refactor add_guardrails_from_policy_engine by extracting two helper
functions to reduce the statement count from 52 to under 50:
- _match_and_track_policies: Handles policy matching and tracking
- _apply_resolved_guardrails_to_metadata: Handles guardrail resolution
Fixes Ruff PLR0915 linting error (too many statements).
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
* fix(content_filter.py): fix filter on toxic keywords
* feat: improve toxic/abusive language detection
* fix: additional improvements to nsfw filters
* feat: more improvements to nsfw filter
* feat(content_filter.json): add new australia specific nsfw content filter
ensure complete coverage for australia nsfw
* fix: cleanup policy templates
* fix(index.tsx): alert notice
* fix(index.tsx): add disclaimer notice
* feat(harmful_child_safety.yaml): new child safety content filter
ensure we catch inappropriate, child-specific content
* feat(policy_templates.json): add child safety and self harm filters
* fix(content_filter.py): improve racial bias filter to use a similar identifier + block word pattern and cover a wider range of ethnicities
* feat(policy_templates.json): add racial bias to nsfw policy template
* feat: add json content viewer
Remove unused local variable 'original_guardrails' that was assigned
but never used in the _execute_guardrail_step method.
Fixes Ruff F841 linting error.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>