litellm/tests/test_litellm/proxy/pass_through_endpoints
yucheng-berri ccd76dac50
fix(proxy): wire team-level logging callbacks into passthrough endpoints (#38979)
* fix(proxy): wire team-level logging callbacks into passthrough endpoints

LIT-5152: passthrough routes now wire dynamic team-level callbacks
(success_callback, failure_callback, callback_vars) into Logging constructor,
mirroring the add_litellm_data_to_request behavior. Three hardening fixes:

1. Catch TypeError/AttributeError in _get_validated_callback_metadata when
   team logging metadata has wrong shape (e.g., logging list instead of dict),
   preventing HTTP 500 on passthrough routes with malformed config.

2. Wrap websocket passthrough logging initialization in try/except, since
   the socket is already accepted at that point; errors after accept() yield
   abrupt close (1006/1011) rather than clean HTTP error response.

3. Handle malformed deprecated callback_settings gracefully with try/except.

4. Wrap HTTP passthrough callback resolution in try/except to prevent 500 on
   malformed team metadata (backward-compatibility fix).

Changes:
- pass_through_endpoints.py: wire dynamic callbacks in HTTP+WS paths, handle
  malformed metadata gracefully with try/except fallbacks
- litellm_pre_call_utils.py: expand exception handling in validators
- test file: regression test for happy-path team callback wiring

* refactor(proxy): share passthrough team-callback resolution and cover its fail-open path

Collapse the duplicated callback wiring on the HTTP and websocket passthrough
paths into one helper that returns a frozen wiring value, log resolution
failures at error level so a broken logging config stays visible, and add
regression tests for malformed team metadata and an operational lookup failure.

Reverts the _get_validated_callback_metadata except widening: it changed
behavior for normal LLM routes, which is outside this ticket's scope.

* fix(proxy): keep passthrough alive when team callback vars hold env references

The deprecated team_metadata.callback_settings branch builds
TeamCallbackMetadata directly, skipping the AddTeamCallback validation
that strips os.environ/ references from the newer logging list. Stamping
those vars onto the Logging object made its constructor raise, so a team
on the legacy shape got HTTP 500 on every passthrough call. Validate the
resolved vars inside the fail-open boundary instead, so the request goes
through with dynamic callbacks skipped and the reason logged.

* fix(proxy): lint violations in team callback wiring helper

* style: format lint
2026-09-01 02:38:39 +00:00
..
llm_provider_handlers fix(anthropic): scale cache costs by fast mode and trust served speed 2026-08-26 11:24:12 -07:00
test_carry_guardrail_logging_info.py fix(passthrough): emit otel guardrail span when a guardrail blocks (#29470) 2026-06-02 11:46:25 -07:00
test_llm_pass_through_endpoints.py fix(gigachat): correct cached-token accounting, stream usage on all finish reasons, stop mutating cached request body 2026-08-31 14:28:30 -07:00
test_managed_id_rewriter.py fix(passthrough): recognize CR-only SSE frame delimiters when minting streamed managed ids 2026-08-26 01:36:18 -07:00
test_method_specific_routing.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_pass_through_endpoints.py fix(proxy): wire team-level logging callbacks into passthrough endpoints (#38979) 2026-09-01 02:38:39 +00:00
test_passthrough_auth_default.py test: drop the cwd-relative sys.path.insert calls from the test suite (#37802) 2026-08-22 09:25:58 -07:00
test_passthrough_endpoint_router.py fix: harden vertex live passthrough against client model forms and dict credentials 2026-08-20 03:05:48 -07:00
test_passthrough_endpoints_common_utils.py test(aws): type the new partition test parameters 2026-08-29 02:27:18 -07:00
test_passthrough_guardrail_block_otel_span.py fix: missing span for guardrail passthrough (#29552) 2026-06-03 01:25:15 +00:00
test_passthrough_guardrails.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_passthrough_guardrails_field_targeting.py test: drop the cwd-relative sys.path.insert calls from the test suite (#37802) 2026-08-22 09:25:58 -07:00
test_passthrough_post_call_guardrails.py fix(proxy): strip only the authenticating secret on credential-less Vertex passthrough 2026-08-25 21:04:27 -07:00
test_streaming_handler.py test(pass_through): pin stream pricing tests to injected divergent rate cards 2026-08-26 16:54:05 -07:00
test_streaming_handler_interrupt.py fix(guardrails): match deferred stream dispatch shape per stream owner and defer passthrough logging until guardrail eos 2026-08-29 02:23:12 -07:00
test_upstream_usage_headers.py test: drop the cwd-relative sys.path.insert calls from the test suite (#37802) 2026-08-22 09:25:58 -07:00
test_vertex_ai_batch_passthrough.py feat(batches): aggregate reasoning tokens and per-line pass/fail counts 2026-08-17 11:25:55 -04:00
test_vertex_passthrough_load_balancing.py fix(proxy): strip only the authenticating secret on credential-less Vertex passthrough 2026-08-25 21:04:27 -07:00
test_watsonx_proxy_route.py test: drop the cwd-relative sys.path.insert calls from the test suite (#37802) 2026-08-22 09:25:58 -07:00