From 94e4dd3684f4d3228e8b3d993c6c369cebf69359 Mon Sep 17 00:00:00 2001 From: Urain Ahmad Shah <60431964+urainshah@users.noreply.github.com> Date: Fri, 5 Jun 2026 16:35:29 +0530 Subject: [PATCH] Fix(langfuse): pass httpx_client to Langfuse in langfuse_prompt_management to respect SSL_VERIFY (#29480) * fix(langfuse): pass ssl_verify to Langfuse httpx client * fix_langfuse_ * add unit tests * addressed comments --------- Co-authored-by: shin-berri Co-authored-by: yuneng-jiang --- .../langfuse/langfuse_prompt_management.py | 5 +++ .../test_langfuse_prompt_management.py | 36 +++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/litellm/integrations/langfuse/langfuse_prompt_management.py b/litellm/integrations/langfuse/langfuse_prompt_management.py index b7a565512c6..75e32d4abae 100644 --- a/litellm/integrations/langfuse/langfuse_prompt_management.py +++ b/litellm/integrations/langfuse/langfuse_prompt_management.py @@ -102,6 +102,11 @@ def langfuse_client_init( if Version(langfuse.version.__version__) >= Version("2.6.0"): parameters["sdk_integration"] = "litellm" + from ...llms.custom_httpx.http_handler import _get_httpx_client + + http_client = _get_httpx_client() + parameters["httpx_client"] = http_client.client + client = Langfuse(**parameters) return client diff --git a/tests/test_litellm/integrations/langfuse/test_langfuse_prompt_management.py b/tests/test_litellm/integrations/langfuse/test_langfuse_prompt_management.py index 9b82165cdab..8c5da120dd9 100644 --- a/tests/test_litellm/integrations/langfuse/test_langfuse_prompt_management.py +++ b/tests/test_litellm/integrations/langfuse/test_langfuse_prompt_management.py @@ -3,6 +3,7 @@ from unittest.mock import MagicMock, patch from litellm.integrations.langfuse.langfuse_prompt_management import ( LangfusePromptManagement, + langfuse_client_init, ) @@ -65,3 +66,38 @@ class TestLangfusePromptManagement: mock_run_async.call_args[0][0] == langfuse_prompt_management.async_log_failure_event ) + + def test_langfuse_client_init_passes_httpx_client(self): + mock_langfuse_class = MagicMock() + with ( + patch( + "litellm.integrations.langfuse.langfuse_prompt_management.resolve_langfuse_credentials", + return_value=("pk-1234", "sk-1234", "https://localhost"), + ), + patch( + "litellm.integrations.langfuse.langfuse_prompt_management.LangFuseLogger._get_langfuse_flush_interval", + return_value=1, + ), + patch.dict("sys.modules", {"langfuse": self._mock_langfuse}), + patch( + "litellm.llms.custom_httpx.http_handler._get_httpx_client" + ) as mock_get_httpx, + ): + mock_http_handler = MagicMock() + mock_http_handler.client = MagicMock() + mock_get_httpx.return_value = mock_http_handler + + self._mock_langfuse.Langfuse = mock_langfuse_class + + langfuse_client_init( + langfuse_public_key="pk-1234", + langfuse_secret="sk-1234", + langfuse_host="https://localhost", + ) + + mock_langfuse_class.assert_called_once() + call_kwargs = mock_langfuse_class.call_args[1] + assert "httpx_client" in call_kwargs + assert call_kwargs["httpx_client"] is mock_http_handler.client + + langfuse_client_init.cache_clear()