litellm/tests/test_litellm/proxy/utils/proxy_logging
devin-ai-integration[bot] 26bf575f15
feat(guardrails): scan retrieved vector store chunks with the request's pre-call guardrails (#43271)
* feat(guardrails): scan retrieved vector store chunks with the request's pre-call guardrails

Vector store retrieval runs inside acompletion after the proxy's pre-call
guardrails have already seen the request, so a retrieved chunk carrying an
injection reached the prompt unscanned. Each retrieved context message now
goes through every pre-call guardrail the request is subject to before it
is injected: a block raises the same 400 the guardrail gives for user text,
a masking guardrail rewrites the context, and a guardrail that fails while
scanning fails the request instead of injecting the chunk unscanned

* fix(guardrails): return a guardrail block unmapped from exception_type so the Responses API surfaces the guardrail's own 400

* fix(guardrails): build the deployment hooks' identity from stamped metadata only

Top-level user_api_key_* fields in a request body are client controlled, so the pre-call, chunk scan, and post-call deployment hooks now take UserAPIKeyAuth from the metadata the proxy stamped, and the chunk scanner returns or raises on every branch.

* fix(guardrails): block route verdicts on retrieved chunks, keep guardrail verdicts out of router retries and fallbacks, and scan chunks against the client's request

* fix(guardrails): keep the merged guardrail list when scanning chunks against the client's request

The scan request laid the client's kept body over the deployment kwargs, so a client
that sent its own top-level guardrails list shadowed the merged metadata.guardrails
list and a key or team guardrail skipped the chunk scan. The kwargs now win and the
keys the proxy relocates into metadata are dropped from the body's contribution.

* fix(guardrails): strip the deployment's guardrail keys from the chunk scan request so merged team guardrails still run

* test(guardrails): type the vector store scan test doubles

* test(guardrails): type the scan double's request data

---------

Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com>
2026-09-26 14:18:38 -07:00
..
__init__.py test(proxy/utils): pin ProxyLogging behavior (#29485) 2026-06-02 17:45:39 -07:00
_harness_smoke_test.py test(proxy/utils): pin ProxyLogging behavior (#29485) 2026-06-02 17:45:39 -07:00
conftest.py test(proxy/utils): pin ProxyLogging behavior (#29485) 2026-06-02 17:45:39 -07:00
test_alerting.py fix(proxy): deliver budget alerts on webhook-only alerting and accept ALERTING_WEBHOOK_URL (#38441) 2026-08-31 09:22:36 -07:00
test_callback_capabilities_class.py test: require a match= on broad pytest.raises, and drop duplicate parametrize cases (#37769) 2026-08-20 20:24:49 -07:00
test_callback_capabilities_dataclass.py test(proxy/utils): pin ProxyLogging behavior (#29485) 2026-06-02 17:45:39 -07:00
test_during_call_hook.py fix(proxy): name the blocking guardrail in x-litellm-applied-guardrails 2026-09-17 08:39:01 +00:00
test_guardrail_pipeline.py fix(policy_engine): keep the per-choice rebuilt response's choices a list so legacy hook rewrites survive the model_dump round-trip 2026-09-18 23:53:02 -07:00
test_internal_usage_cache.py test(proxy/utils): pin ProxyLogging behavior (#29485) 2026-06-02 17:45:39 -07:00
test_lifecycle.py fix(proxy): remove duplicate user budget hook that 429'd zero-cost models 2026-09-16 15:42:15 -07:00
test_mcp_bridging.py fix(mcp): retain selected guardrails for virtual REST calls 2026-09-17 10:40:33 -07:00
test_module_helpers.py feat(guardrails): scan retrieved vector store chunks with the request's pre-call guardrails (#43271) 2026-09-26 14:18:38 -07:00
test_post_call_failure_hook.py fix(proxy): keep deployment labels on cache-hit post_call guardrail rejections (#42780) 2026-09-23 22:48:04 -07:00
test_post_call_success_hook.py fix(proxy): name the blocking guardrail in x-litellm-applied-guardrails 2026-09-17 08:39:01 +00:00
test_pre_call_hook.py fix(mcp): keep tool attribution on guardrail-blocked REST calls (#42790) 2026-09-23 15:40:56 -07:00
test_streaming_hooks.py refactor(anthropic): rename experimental_pass_through to pass_through (#43329) 2026-09-26 13:00:50 -07:00