From 6aab6451c497690cd54589b7d39b4e95bdde4170 Mon Sep 17 00:00:00 2001 From: huangpz6 Date: Thu, 5 Nov 2026 12:45:44 +0800 Subject: [PATCH] fix(bitbucket): use the configured base_url BitBucketClient read config.get("", ...) instead of config.get("base_url", ...), so a custom BitBucket API base URL was ignored and every request went to api.bitbucket.org. Read the documented key and cover it with a request-URL test. Closes #50158 --- .../bitbucket/bitbucket_client.py | 2 +- .../test_bitbucket_prompt_manager.py | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/litellm/integrations/bitbucket/bitbucket_client.py b/litellm/integrations/bitbucket/bitbucket_client.py index e4f5a50550e..7549bae6fcd 100644 --- a/litellm/integrations/bitbucket/bitbucket_client.py +++ b/litellm/integrations/bitbucket/bitbucket_client.py @@ -80,7 +80,7 @@ class BitBucketClient: self.repository = config.get("repository") self.access_token = config.get("access_token") self.branch = config.get("branch", "main") - self.base_url = config.get("", "https://api.bitbucket.org/2.0") + self.base_url = config.get("base_url", "https://api.bitbucket.org/2.0") self.auth_method = config.get("auth_method", "token") self.username = config.get("username") diff --git a/tests/unit/integrations/bitbucket/test_bitbucket_prompt_manager.py b/tests/unit/integrations/bitbucket/test_bitbucket_prompt_manager.py index a1a88653ee6..7e2f6e59a99 100644 --- a/tests/unit/integrations/bitbucket/test_bitbucket_prompt_manager.py +++ b/tests/unit/integrations/bitbucket/test_bitbucket_prompt_manager.py @@ -65,6 +65,28 @@ def test_bitbucket_client_initialization(): assert client_basic.username == "test-user" +def test_bitbucket_client_uses_configured_base_url(): + config = { + "workspace": "test-workspace", + "repository": "test-repo", + "access_token": "test-token", + "base_url": "https://bitbucket.example.com/2.0", + } + + with patch("litellm.integrations.bitbucket.bitbucket_client.HTTPHandler") as handler_cls: + client = BitBucketClient(config) + handler_cls.return_value.get.return_value = MagicMock( + headers={"content-type": "text/plain"}, text="prompt" + ) + + client.get_file_content("prompts/test.prompt") + + assert ( + handler_cls.return_value.get.call_args.args[0] + == "https://bitbucket.example.com/2.0/repositories/test-workspace/test-repo/src/main/prompts/test.prompt" + ) + + def test_bitbucket_client_missing_required_fields(): """Test BitBucketClient initialization with missing required fields.""" with pytest.raises(