Commit Graph
172 Commits
Author SHA1 Message Date
Sameer KankuteandGitHub e7efd51bd7 Merge branch 'main' into litellm_staging_01_06_2026 2026-01-09 17:06:17 +05:30
Sameer KankuteandGitHub 844c766c65 Merge pull request #18763 from BerriAI/litellm_staging_01_07_2026
Staging - 01/07/2026
2026-01-09 17:01:58 +05:30
Yuta Saito 48bc5ccb4f fix: test 2026-01-09 11:23:47 +09:00
Yuta Saito f129f598a0 fix: how to execute cloudzero sql 2026-01-09 10:52:48 +09:00
YutaSaitoandGitHub 661f03058c Merge pull request #18802 from BerriAI/litellm_feat_focus_backend
[feat] Focus export support
2026-01-09 07:21:04 +09:00
Yuta Saito 271ee0959b test: focus 2026-01-08 16:53:09 +09:00
Alexsander HamirandGitHub 2f803171d6 refactor(prometheus): skip metrics for invalid API key requests (#18788) 2026-01-07 17:14:14 -08:00
1b8708fccc Litellm embeddings calltype fix for guardrail precallhook (#18740)
* adding signoz integration to observability docs

* Fixing build

* Adding timeout for flaky test

* Fixing e2e

* add team member budget duration in team/update

* Reusable Duration Select and update team member budget UI

* feat: allow configuring project name for OpenTelemetry service name

* docs: sets ARIZE_PROJECT_NAME

* added valid callType for bedrock guardrail pre hook

This is to resolve the error when bedrock guardrails are enabled and invoke the embedding models.   {"error":{"message":"'embeddings' is not a valid CallTypes","type":"None","param":"None","code":"500"}}*

* updated the test case to reflect valid callType

---------

Co-authored-by: Goutham Karthi <goutham@signoz.io>
Co-authored-by: yuneng-jiang <yuneng.jiang@gmail.com>
Co-authored-by: YutaSaito <36355491+uc4w6c@users.noreply.github.com>
Co-authored-by: Yuta Saito <uc4w6c@bma.biglobe.ne.jp>
2026-01-07 21:40:36 +05:30
Harshit JainandGitHub 92f7789f10 feat(prometheus): add caching metrics (#18755) 2026-01-07 21:29:04 +05:30
Ishaan Jaffer 6122ff9fce TestEncryptResponseId 2026-01-07 21:03:22 +05:30
Ishaan Jaffer b855ad5541 test_encode_decode_helpers_roundtrip_in_cache_context 2026-01-07 18:23:17 +05:30
Ishaan Jaffer dd67235d4d TestLevoIntegration 2026-01-07 18:17:22 +05:30
Yuta Saito 1d16a8526e feat: allow configuring project name for OpenTelemetry service name 2026-01-07 14:20:10 +09:00
Krish DholakiaandGitHub 7004734528 Revert "feat: Add built-in migration lock to prevent concurrent Prisma migrat…" (#18719)
This reverts commit 9f68081f6d.
2026-01-06 23:56:02 +05:30
Hamza QureshiandGitHub 9c544949f8 feat: Add Prometheus metrics for request queue time and guardrails (#17973)
* feat: Add Prometheus metrics for request queue time and guardrails

- Add litellm_request_queue_time_seconds metric to track time from request arrival to processing start
- Add guardrail metrics: latency, errors_total, and requests_total counters
- Track arrival time in litellm_pre_call_utils.py
- Calculate queue time in common_request_processing.py
- Record guardrail metrics in pre_call_hook and during_call_hook
- Add comprehensive unit tests for all new metrics

Fixes #17863

* perf: optimize timing calls for queue time and guardrail metrics

* fix: resolve conflicts in utils.py - integrate Prometheus metrics with guardrail load balancing
2026-01-06 23:50:11 +05:30
+10 9f68081f6d feat: Add built-in migration lock to prevent concurrent Prisma migrate deploy (#14440)
* feat: prisma migrate deploy with lock
Author: Mini Jeong <mini.jeong@navercorp.com>

* fix: use redis cache from proxy server
Author: Mini Jeong <mini.jeong@navercorp.com>

* fix: add type checks and fix unit tests for migration lock

- Add DATABASE_URL validation in _create_baseline_migration() and _resolve_all_migrations()
- Fix MyPy type errors by adding None checks before using database_url in subprocess calls
- Add _resolve_all_migrations mock to failing unit tests to prevent filesystem errors
- Apply Black formatting to modified files

Fixes:
- MyPy type errors: database_url could be None when passed to subprocess
- Unit test failures: _resolve_all_migrations tried to create directories in read-only /test path

* fix: resolve MyPy type error in vertex_ai vertex_llm_base

Fix MyPy type checking error where vertex_api_version parameter type
was incompatible with function signature expectation.

* fix: Return 403 exception when calling GET responses api

* fix: added new step into rotate master key function for processing credentials table

* Add redisvl in requirements.txt

* fix: fixed the issue of handling root paths when processing Discovery protected resource metadata and authorization server metadata URLs.

* fix: added additional grant type into oauth_authorization_server response for fixing mcp auth register bad request issue

* fix: added RFC RECOMMENDED property(scopes_supported) to protected resource and authorization server metadata

* fix: removed initialize the tool name to MCP server name mapping(oauth2) on startup for avoiding 401 error

* fix: upgraded mcp sdk depency version for fixing ClosedResourceError

* Use already configured opentelemetry providers

Users that instrument using opentelemetry-instrument can now setup exporters as per their environment.

* Handle all protocols for all telemetry

* Add more tests

* feat(mcp): parallelize tool fetching from multiple MCP servers (#18627)

* feat(mcp): parallelize tool fetching from multiple MCP servers

Replace sequential tool fetching with asyncio.gather() to reduce
client timeouts when using multiple MCP servers.

Changes:
- mcp_server_manager.py: list_tools() now fetches tools in parallel
- server.py: _get_tools_from_mcp_servers() now fetches tools in parallel

Real-world impact (7 MCP servers example):
- Sequential: ~4.5+ seconds (exceeds typical 5-second client timeouts)
- Parallel: ~1.2 seconds (max of all servers)

Fixes #18626

* fix: copy oauth2_headers to avoid shared dict mutation in parallel tasks

* feat: add display_name, model_vendor, and model_version metadata

* added the option of adding langsmith tenant id in the env (#18623)

* fix(router): Validate routing_strategy at startup to fail fast with helpful error. (#18624)

Invalid routing_strategy values (e.g., "simple" instead of "simple-shuffle") previously failed silently, causing confusing "No deployments available" errors downstream. This change adds upfront validation in routing_strategy_init() to:

- Check if the provided strategy matches valid string values or RoutingStrategy enum
- Raise a clear ValueError listing valid options if invalid
- Fail fast at startup instead of at request time

Fixes behavior reported in #11330 where users had to debug cryptic errors.

Valid strategies: simple-shuffle, least-busy, usage-based-routing, latency-based-routing, cost-based-routing, usage-based-routing-v2

Co-authored-by: Flibbert E. Gibbitz <flibbertygibbitz@runelabs.ai>

* Add libsndfile to database Docker image for audio processing (#18612)

The litellm-database Docker image was missing the libsndfile system
library, which is required by the soundfile Python package for audio
file processing. This caused failures when using audio transcription
endpoints that attempt to calculate audio duration.

This adds libsndfile to the runtime dependencies in Dockerfile.database,
consistent with Dockerfile.alpine which already includes this library.

* Fix: Map Gemini cached_tokens to Langfuse cache_read_input_tokens (#18614)

* Fix: Map Gemini cached_tokens to Langfuse cache_read_input_tokens

Fixes #18520

## Problem
Langfuse integration was not capturing cached tokens from Gemini models.
Gemini returns cached tokens in `usage.prompt_tokens_details.cached_tokens`,
but Langfuse only read from top-level `usage.cache_read_input_tokens`
(which only Anthropic populates).

## Solution
Updated langfuse.py to check both locations:
1. First check top-level cache_read_input_tokens (for Anthropic)
2. Then check prompt_tokens_details.cached_tokens (for Gemini, OpenAI, others)

This ensures all providers' cached tokens are properly reported to Langfuse.

## Changes
- Modified litellm/integrations/langfuse/langfuse.py (lines 742-761)
- Added 3 unit tests in tests/test_litellm/integrations/langfuse/test_gemini_cached_tokens.py
- All existing Langfuse tests still pass (11/11)

## Testing
- test_cached_tokens_extraction: Verifies Gemini cached_tokens extraction
- test_cached_tokens_not_present: Backward compatibility (no cached_tokens)
- test_cached_tokens_is_zero: Edge case when cached_tokens = 0

* Refactor: Extract cache token logic into helper function

Address review feedback from @officer47p

- Created _extract_cache_read_input_tokens() helper function
- Reduces code bloat in _log_langfuse_v2 method
- Improves testability and reusability
- All tests still passing (11/11)

* Adding Role Mappings

* Fixing Edit SSO Settings Modal

* feat: add user_mcp_management_mode for view_all visibility

* Fixing tests

* fix: missing mcp_allow_all_ui.png

* docs: add user_mcp_management_mode

* Align responses API streaming hooks with chat pipeline

* Clarify responses API streaming context

* Address review comments

* feat: Add GigaChat provider support (#18564)

* feat: Add GigaChat provider support

Add native support for GigaChat API (Sber AI, Russia's leading LLM).

Supported features:
- Chat completions (sync/async)
- Streaming (sync/async)
- Function calling / Tools
- Structured output via JSON schema (emulated through function calls)
- Image input (base64 and URL)
- Embeddings

Closes #18515

* fix: resolve mypy type errors in GigaChat handler

- Fix _prepare_file_data return type (use 3-tuple for cleaner type flow)
- Add type annotations for lists in _process_content_parts methods
- Add type annotations in _collapse_user_messages
- Use ChatCompletionToolCallChunk for proper tool_use typing
- Add type: ignore[override] for astreaming async generator

* refactor(gigachat): migrate to BaseConfig pattern

* fix: remove unused imports

* fix: resolve mypy type errors

* fix: mypy type errors

* refactor: address review feedback for GigaChat provider

- Remove singleton pattern, reuse litellm HTTPHandler
- Move constants/errors to transformation files, delete common_utils.py
- Add models to model_prices_and_context_window.json
- Fix ssl_verify not passed to HTTP client for embeddings

* docs: update GigaChat documentation with ssl_verify requirement

* Revert "Add redisvl in requirements.txt"

* Put reasoning summary behind feat flag

* fix: model eol

* fix: anthropic claude-3-opus-20240229 EOL

* Revert "fix: model eol"

This reverts commit 5aa1665d79.

* Fix: ImportError: qualifire package is required for QualifireGuardrail. Install it with: pip install qualifire

* fix: test_secret_manager_failure_does_not_block_email

* fix: test_update_ui_settings_allowlisted_value

* fix: test_aaamodel_prices_and_context_window_json_is_valid

* fix: test_all_models_have_display_name

* fix: async def test_bedrock_apply_guardrail_blocked()

* fix: test_databricks_embeddings[True]

* fix:test_anthropic_beta_header

* fix:test_api_error_handling

* fix:mypy mcp management

* Revert "feat(model_cost): add display_name, model_vendor, and model_version metadata to model entries"

* [Feat] New API Endpoint - Responses API (v1/responses/compact) (#18697)

* init transform_compact_response_api_request

* init acompact_responses

* init async_compact_response_api_handler in llm http handler

* init transform_compact_response_api_request for openai

* init acompact_responses

* fix acompact_responses

* add OAI Compact API

* docs responses API Compact

* code qa checks

* test_openai_compact_responses_api

* fix mypy linting

* fix: remove display name

* Add the LITELLM_REASONING_AUTO_SUMMARY in doc

* fix model map

* [UI] - Feat add request provider form on UI (#18704)

* add request provider form

* fix link to github

* add button

* fix link

* fix(streaming): normalize status code extraction to prevent 4xx errors from triggering mid-stream fallback (#18698)

在流式处理错误时,添加状态码标准化逻辑,确保 4xx 客户端错误直接抛出而不是被包装成 MidStreamFallbackError。

- 新增 _normalize_status_code 函数用于从异常对象提取状态码
- 优先从异常的 status_code 属性获取,其次从 response.status_code 获取
- 当映射异常或原始异常的状态码在 400-499 范围内时,直接抛出映射异常
- 添加单元测试验证 Vertex AI 400 错误正确抛出为 BadRequestError
- 确保流式处理中的客户端错误能够正确传播,而不会触发回退机制

---------

Co-authored-by: Eric84626 <lixiannan@gmail.com>
Co-authored-by: Eric84626 <97266539+Eric84626@users.noreply.github.com>
Co-authored-by: Sameer Kankute <sameer@berri.ai>
Co-authored-by: mangabits <1457532+mangabits@users.noreply.github.com>
Co-authored-by: Costa Tsaousis <costa@tsaousis.gr>
Co-authored-by: Nik <nikolas.garza5@gmail.com>
Co-authored-by: Shivam Rawat <161387515+shivamrawat1@users.noreply.github.com>
Co-authored-by: FlibbertyGibbitz <seth@evenkeelconsultingllc.com>
Co-authored-by: Flibbert E. Gibbitz <flibbertygibbitz@runelabs.ai>
Co-authored-by: Cesar Garcia <128240629+Chesars@users.noreply.github.com>
Co-authored-by: yuneng-jiang <yuneng.jiang@gmail.com>
Co-authored-by: Yuta Saito <uc4w6c@bma.biglobe.ne.jp>
Co-authored-by: LingXuanYin <3546599908@qq.com>
Co-authored-by: YutaSaito <36355491+uc4w6c@users.noreply.github.com>
Co-authored-by: 0717376 <103773680+0717376@users.noreply.github.com>
Co-authored-by: Ishaan Jaff <ishaanjaffer0324@gmail.com>
Co-authored-by: Kris Xia <xiajiayi0506@gmail.com>
Co-authored-by: Krish Dholakia <krrishdholakia@gmail.com>
2026-01-06 23:46:24 +05:30
Sameer KankuteandGitHub 3c0248edb9 Merge pull request #18663 from BerriAI/litellm_staging_01_05_2026
Staging 01/05/2026
2026-01-06 10:46:04 +05:30
YutaSaitoandGitHub ccdcb20048 Merge pull request #18279 from mangabits/fix-otel-provider
Use already configured opentelemetry providers
2026-01-06 12:49:48 +09:00
Cesar GarciaandGitHub 0e601d0bfe Fix: Map Gemini cached_tokens to Langfuse cache_read_input_tokens (#18614)
* Fix: Map Gemini cached_tokens to Langfuse cache_read_input_tokens

Fixes #18520

## Problem
Langfuse integration was not capturing cached tokens from Gemini models.
Gemini returns cached tokens in `usage.prompt_tokens_details.cached_tokens`,
but Langfuse only read from top-level `usage.cache_read_input_tokens`
(which only Anthropic populates).

## Solution
Updated langfuse.py to check both locations:
1. First check top-level cache_read_input_tokens (for Anthropic)
2. Then check prompt_tokens_details.cached_tokens (for Gemini, OpenAI, others)

This ensures all providers' cached tokens are properly reported to Langfuse.

## Changes
- Modified litellm/integrations/langfuse/langfuse.py (lines 742-761)
- Added 3 unit tests in tests/test_litellm/integrations/langfuse/test_gemini_cached_tokens.py
- All existing Langfuse tests still pass (11/11)

## Testing
- test_cached_tokens_extraction: Verifies Gemini cached_tokens extraction
- test_cached_tokens_not_present: Backward compatibility (no cached_tokens)
- test_cached_tokens_is_zero: Edge case when cached_tokens = 0

* Refactor: Extract cache token logic into helper function

Address review feedback from @officer47p

- Created _extract_cache_read_input_tokens() helper function
- Reduces code bloat in _log_langfuse_v2 method
- Improves testability and reusability
- All tests still passing (11/11)
2026-01-06 01:34:09 +05:30
Yuta Saito bdc35b4cd2 tests: mock LiteLLM_UserTable for CloudZero export 2026-01-05 17:23:04 +09:00
YutaSaitoandGitHub c405135c2b Merge pull request #18584 from BerriAI/feat/add_user_email_to_cloudzero
feat: add user email to cloudzero
2026-01-05 14:22:46 +09:00
amangupta-20andGitHub 399579f8ea feat: Add Levo AI integration (#18529) 2026-01-05 08:49:21 +05:30
lifandGitHub 7d81d245fb fix: align prometheus metric names with DEFINED_PROMETHEUS_METRICS (#18463)
Fix metric name inconsistency for litellm_remaining_requests_metric
and litellm_remaining_tokens_metric. The factory received names
without the _metric suffix, causing _is_metric_enabled to fail when
users configured these metrics in prometheus_metrics_config.

Fixes #18221

Signed-off-by: majiayu000 <1835304752@qq.com>
2026-01-04 00:48:09 +05:30
Yuta Saito da05b56756 feat: add user email to cloudzero 2026-01-02 17:48:16 +09:00
mangabits 4a1bc90e61 Add more tests 2026-01-01 19:08:34 -08:00
mangabits 78693bb9d0 Use already configured opentelemetry providers
Users that instrument using opentelemetry-instrument can now setup exporters as per their environment.
2026-01-01 19:06:55 -08:00
Yuta Saito b343d15157 fix: prevent LiteLLM from closing external OTEL spans 2026-01-01 08:28:48 +09:00
Yuta Saito 6888d34ea5 feat: Log actual executed event type in guardrail logging 2025-12-27 07:20:24 +09:00
Yuta Saito 61e1e42e97 fix: Datadog span kind fallback when parent_id missing 2025-12-24 14:12:17 +09:00
Alexsander HamirandGitHub 5534038e93 Fix CI: Revert security scan changes and add GitGuardian ignore rules (#18358) 2025-12-22 17:03:53 -08:00
Ishaan Jaffer 6112160a16 Revert "[Fix] Security - Remove example API keys with high entropy (#18255)"
This reverts commit 24edbccf5c.
2025-12-20 20:48:11 +05:30
YutaSaitoandGitHub 2bbfa498e2 Revert "ensure datadog llm obs ignores dd base url override" 2025-12-20 08:56:49 +09:00
Yuta Saito 72f424c719 ensure datadog llm obs ignores dd base url override 2025-12-20 07:44:40 +09:00
Sameer KankuteandGitHub f05e600969 Merge pull request #18236 from BerriAI/litellm_add_background_responses_cost_tracking
Add cost tracking for responses api in background mode
2025-12-20 00:14:09 +05:30
Alexsander HamirandGitHub 24edbccf5c [Fix] Security - Remove example API keys with high entropy (#18255) 2025-12-19 10:09:50 -08:00
YutaSaitoandGitHub 3c380086b6 Merge pull request #18234 from BerriAI/litellm_fix_not_working_failure_logging
fix: not working log_failure_event in langfuse
2025-12-19 17:32:05 +09:00
Sameer Kankute 7d0f41f437 Add cost tracking for responses api in background mode 2025-12-19 13:35:48 +05:30
Yuta Saito 20bbfdd7cb fix: not working log_failure_event in langfuse 2025-12-19 16:54:57 +09:00
Sameer KankuteandGitHub 1fd4f1ba52 Merge pull request #18109 from BerriAI/litellm_fix_custom_gaurdrail_fix
Fix guardrails for passthrough endpoint
2025-12-19 08:36:58 +05:30
Ishaan JaffandGitHub 539f629eff [Feat] New Logging Integration - Azure Sentinel Logger (#18146)
* add AzureSentinelLogger

* logging: AzureSentinelLogger

* test_azure_sentinel_signature_and_send_batch

* docs azure sentinel

* fix AzureSentinelLogger

* test fix

* docs fix

* fix: AzureSentinelLogger

* docs sentintel

* feat: add example SLP

* docs sentinel

* docs fix

* docs fix

* docs fix

* fix code qa

* QA fix

* fix test

* TestInitializeInteractionsEndpoints
2025-12-18 02:04:49 +05:30
Sameer Kankute b7550ea2d4 Add test for gaurdrail in passthrough 2025-12-17 12:52:21 +05:30
Alexsander HamirandGitHub 1393c76578 [Fix] CI/CD - Fix failing proxy and core integration tests (#17926)
* Fix: Add prisma generate to proxy tests CI job

- Add prisma generate command before pytest in litellm_mapped_tests_proxy job
- Fixes 3 test failures: test_health_liveliness_endpoint, test_health_liveness_endpoint, test_health_readiness
- Matches pattern used in litellm_mapped_enterprise_tests job

* Fix: Add missing prompt_spec parameter to TestCustomPromptManagement

- Add prompt_spec parameter to get_chat_completion_prompt() method signature
- Fixes 2 test failures: test_custom_prompt_management_with_prompt_id and test_custom_prompt_management_with_prompt_id_and_prompt_variables
- Aligns test mock with base class method signature from CustomPromptManagement

* Fix: Handle string datetime values in OpenTelemetry timestamp conversion

- Add _to_timestamp helper to handle datetime, float, and string inputs
- Fixes test_handle_success_spans_and_metrics failure
- Handles string datetime format from JSON deserialization (e.g. '2025-06-22 10:59:08.399523')
- Applied to all timestamp conversions in OpenTelemetry metrics methods

* Fix OpenTelemetry timestamp parsing to handle datetime strings with/without microseconds
2025-12-13 10:11:01 -08:00
YutaSaitoandGitHub 13df50830d chore: prefer standard trace id for Langfuse logging (#17791) 2025-12-11 08:18:45 -08:00
Krish DholakiaandGitHub b0a5a4b81d Arize Phoenix OSS - Prompt Management Integration (#17750)
* docs(prompt_management.md): document how to onboard prompts to litellm

* feat(arize_phoenix_prompt_manager.py): support new prompt management integration

allows users to connect arize phoenix prompt manager to litellm

* fix(proxy/utils.py): remove prompt variables to avoid re-processing prompt

* docs(arize_phoenix_prompts.md): document new prompt management integration
2025-12-09 22:53:42 -08:00
YutaSaitoandGitHub 80a18f989a feat: propagate Langfuse trace_id (#17669) 2025-12-09 12:25:52 -08:00
Alexsander HamirandGitHub 1254a92e66 fix: make test_log_langfuse_v2_handles_null_usage_values more robust (#17599)
- Reset mock call counts at start of test to ensure clean state
- Add span method to mock trace to handle log_provider_specific_information_as_span calls
- Re-establish mock chain before test call to ensure fresh state
- Add exception handling to catch and report errors during test execution
- Add verification that trace was called before checking generation

This should fix the flaky test that was failing intermittently with
'Expected generation to have been called once. Called 0 times.'
2025-12-06 09:21:00 -08:00
Alexsander HamirandGitHub 1e89aa3068 Fix: Resolve flakiness in three integration tests (#17594)
Fixed three flaky tests that were intermittently failing in CI:

1. test_no_duplicate_spend_logs (test_litellm/responses/test_no_duplicate_spend_logs.py)
   Problem: Used await asyncio.sleep(1) to wait for async logging completion,
            which created race conditions. The async logging worker queues tasks
            in the background, and sleep() doesn't guarantee completion.

   Fix: Replaced sleep() with GLOBAL_LOGGING_WORKER.flush() which properly waits
        for the logging queue to empty, ensuring all async logging tasks complete
        before assertions run.

2. test_log_langfuse_v2_handles_null_usage_values (test_litellm/integrations/test_langfuse.py)
   Problem: Used datetime.datetime.now() twice for start_time and end_time, which
            could cause timing inconsistencies between test runs, especially in
            CI environments with variable execution speeds.

   Fix: Use fixed timestamps instead of datetime.now() to ensure consistent timing
        across all test runs, eliminating timing-related flakiness.

3. test_watsonx_gpt_oss_prompt_transformation (test_litellm/llms/watsonx/test_watsonx.py)
   Problem: Directly accessed mock_post.call_args without checking if it exists,
            which could be None if the mock wasn't called or if an exception
            occurred before the POST request. The test catches exceptions and
            continues, making this a potential failure point.

   Fix: Added proper assertions and use call_args_list[0] for safer access:
        - Assert that call_args_list has at least one call
        - Assert that call_args is not None
        - Assert that 'data' key exists in kwargs
        This ensures the test fails with clear error messages rather than
        intermittent AttributeError exceptions.

All fixes maintain the original test intent while making them deterministic
and reliable in CI environments.
2025-12-06 07:57:03 -08:00
Alexsander HamirandGitHub 3db6d2a1ed Reapply Langfuse logger test mock setup fix (#17591)
Reapplies the fix from commit a885e21543 that was
reverted in 6c9556be67.

The original revert was done because the test was flaky and giving false
negatives. This fix properly mocks the Langfuse client to ensure the test
can correctly verify that _log_langfuse_v2 converts None usage values to 0.

Changes:
- Add mock_langfuse_client.client attribute to prevent errors during init
- Add trace_id to mock_langfuse_generation for proper return value handling
- Remove redundant mock setup code
- Explicitly set logger.Langfuse to mock client after initialization
- Set logger.langfuse_sdk_version to ensure _supports_* methods work correctly
2025-12-06 07:26:34 -08:00
Alexsander HamirandGitHub 6c9556be67 Revert "Fix Langfuse logger test mock setup (#17588)" (#17590)
This reverts commit a885e21543.
2025-12-06 06:25:47 -08:00
Alexsander HamirandGitHub a885e21543 Fix Langfuse logger test mock setup (#17588)
* Fix test_log_langfuse_v2_handles_null_usage_values test failure

The test was failing because the logger's Langfuse client wasn't properly
mocked. Even though sys.modules was mocked, the logger's __init__ method
creates its own Langfuse client instance that wasn't using the test's mock.

Changes:
- Explicitly set logger.Langfuse to the mock client after initialization
- Set logger.langfuse_sdk_version to ensure _supports_* methods work correctly
- Added mock_langfuse_client.client attribute to prevent errors during init
- Added trace_id to mock_langfuse_generation for proper return value handling
- Removed redundant mock setup code

This ensures the test can properly verify that _log_langfuse_v2 correctly
converts None usage values to 0 by allowing the mock's generation method
to be called and asserted.

Fixes: AssertionError: Expected 'generation' to have been called once. Called 0 times.
2025-12-06 05:56:24 -08:00