The test_sso_key_generate_shows_deprecation_banner test was failing in CI
with a 403 Forbidden error because the SSO endpoint checks for premium_user
at line 297 in ui_sso.py.
The fix adds a monkeypatch for premium_user at its source location
(litellm.proxy.proxy_server.premium_user) to bypass the enterprise check
during testing.
Fixes the intermittent test failure where the endpoint would return 403
instead of the expected 200 status code.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
The Reasoning import was left unused after PR #21103 changed
reasoning=dict(Reasoning()) to reasoning=None. This caused
a Ruff F401 linting error.
Fixes linting error:
- F401: `litellm.types.llms.openai.Reasoning` imported but unused
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit addresses two issues:
1. **Merge conflict resolution**: Resolved merge conflict in litellm/integrations/opentelemetry.py
that was preventing imports from working. The conflict was in the OpenTelemetry SDK
LogRecord import section.
2. **Test flakiness fix**: Fixed intermittent failures in test_bedrock_converse_budget_tokens_preserved
by properly configuring mock objects to avoid unawaited coroutine warnings.
The test was failing in CI with "Expected 'post' to have been called once. Called 0 times."
The root cause was improper mock setup where AsyncMock was creating async child methods
(raise_for_status, json) that returned unawaited coroutines, causing unreliable behavior
across different Python versions and test environments.
**Changes:**
- Set raise_for_status() and json() as explicit MagicMock instances on the response
- Use AsyncMock explicitly for the post() method via patch.object's 'new' parameter
- This ensures response methods are synchronous while the HTTP call remains async
**Testing:**
- Test now passes consistently across 5 consecutive runs
- RuntimeWarnings about unawaited coroutines eliminated (18 warnings → 16 warnings)
- Request JSON verification shows budget_tokens correctly preserved
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
The manual sys.modules restoration code was redundant because
patch.dict.stop() automatically handles the cleanup. This simplifies
the tearDown method and removes the now-unused _original_langfuse_module
instance variable.
Addresses review comment: https://github.com/BerriAI/litellm/pull/21214#pullrequestreview-3802348462
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Fixes test_log_langfuse_v2_handles_null_usage_values flaky test failure
by properly cleaning up sys.modules['langfuse'] in tearDown.
Changes:
- Store original langfuse module in setUp before mocking
- Restore original or remove mock in tearDown to prevent state pollution
- Remove invalid print_verbose parameter from log_event_on_langfuse
Root Cause:
The tearDown method was not cleaning up sys.modules['langfuse'] after
each test, causing mock state to leak between tests. This caused
intermittent failures in CI, especially when tests run in parallel or
in different orders.
Impact:
This test has a long history of flakiness with multiple attempted fixes
(#20475, #17599, #17594, #17591, #17588). The missing sys.modules cleanup
was the underlying issue causing continued failures despite those patches.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>