Repository navigation
fix(guardrails): stop the Javelin api_version default leaking into Azure Content Safety #41941
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
mateo-berri
merged 3 commits into
main
from
litellm_azure_content_safety_api_version_default
Sep 19, 2026
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
6f4d1c5
fix(guardrails): stop the Javelin api_version default leaking into Az…
mateo-berri 24064e3
fix(guardrails): treat the stored Javelin api_version default as unse…
mateo-berri e327a6a
test(guardrails): drop regression docstrings from the api_version tests
mateo-berri File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
tests/test_litellm/proxy/guardrails/guardrail_hooks/test_javelin.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| from unittest.mock import Mock, patch | ||
|
|
||
| import pytest | ||
|
|
||
| from litellm.proxy.guardrails.guardrail_hooks.javelin.javelin import JavelinGuardrail | ||
| from litellm.proxy.guardrails.guardrail_registry import InMemoryGuardrailHandler | ||
| from litellm.types.guardrails import GuardrailEventHooks | ||
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_config_without_api_version_calls_javelin_v1(): | ||
| """Javelin's v1 default no longer lives in the shared LitellmParams model (it | ||
| leaked into every other provider), so the Javelin initializer has to supply | ||
| it itself when the config omits api_version.""" | ||
| handler = InMemoryGuardrailHandler() | ||
| registered = handler.initialize_guardrail( | ||
| guardrail={ | ||
| "guardrail_name": "javelin-no-api-version", | ||
| "litellm_params": { | ||
| "guardrail": "javelin", | ||
| "mode": "pre_call", | ||
| "api_key": "javelin_api_key", | ||
| "api_base": "https://javelin.example", | ||
| "guard_name": "trustsafety", | ||
| }, | ||
| } | ||
| ) | ||
| assert registered is not None | ||
| guardrail = handler.guardrail_id_to_custom_guardrail[registered["guardrail_id"]] | ||
| assert isinstance(guardrail, JavelinGuardrail) | ||
| assessments = [{"trustsafety": {"request_reject": False}}] | ||
| response = Mock() | ||
| response.json.return_value = {"assessments": assessments} | ||
|
|
||
| with patch.object(guardrail.async_handler, "post", return_value=response) as mock_post: | ||
| result = await guardrail.call_javelin_guard( | ||
| request={"input": {"text": "hello"}, "config": None, "metadata": None}, | ||
| event_type=GuardrailEventHooks.pre_call, | ||
| ) | ||
|
|
||
| assert result == {"assessments": assessments} | ||
| assert mock_post.call_args.kwargs["url"] == "https://javelin.example/v1/guardrail/trustsafety/apply" | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.