diff --git a/litellm/integrations/bitbucket/bitbucket_client.py b/litellm/integrations/bitbucket/bitbucket_client.py index 5ebde5d4fb6..75922696cb7 100644 --- a/litellm/integrations/bitbucket/bitbucket_client.py +++ b/litellm/integrations/bitbucket/bitbucket_client.py @@ -96,7 +96,10 @@ class BitBucketClient: - repository: Repository name - access_token: BitBucket access token (or app password) - branch: Branch to fetch from (default: main) - - base_url: Custom BitBucket API base URL (optional) + - base_url: Custom BitBucket API base URL (optional). Must stay + compatible with the Bitbucket Cloud 2.0 path scheme; Bitbucket Data + Center (Server) REST APIs use different paths and are not supported + by this client. - auth_method: Authentication method ('token' or 'basic', default: 'token') - username: Username for basic auth (optional) """ @@ -104,7 +107,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 b90f563496e..d38947b90cd 100644 --- a/tests/unit/integrations/bitbucket/test_bitbucket_prompt_manager.py +++ b/tests/unit/integrations/bitbucket/test_bitbucket_prompt_manager.py @@ -4,6 +4,7 @@ from unittest.mock import MagicMock, patch import httpx import pytest +import respx from litellm.integrations.bitbucket.bitbucket_client import BitBucketClient @@ -67,6 +68,25 @@ 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 respx.mock: + respx.get( + "https://bitbucket.example.com/2.0/repositories/test-workspace/test-repo/src/main/prompts/test.prompt" + ).mock(return_value=httpx.Response(200, text="prompt", headers={"content-type": "text/plain"})) + client = BitBucketClient(config) + + content = client.get_file_content("prompts/test.prompt") + + assert content == "prompt" + + def test_bitbucket_client_missing_required_fields(): """Test BitBucketClient initialization with missing required fields.""" with pytest.raises(