BerriAI/litellm · error · Exception
Failed to get repository info: {e}
Error message
Failed to get repository info: {e} What it means
Catch-all from BitBucketClient.get_repository_info: a GET to /2.0/repositories/{workspace}/{repo} either returned a non-2xx status (raise_for_status) or the response body failed to parse as JSON. All context is flattened into the message string. This method also backs test_connection(), so a failure here is what makes test_connection() return False.
Source
Thrown at litellm/integrations/bitbucket/bitbucket_client.py:179
raise Exception(f"Failed to list files in '{directory_path}': {e}")
else:
raise Exception(f"Error listing files in '{directory_path}': {e}")
def get_repository_info(self) -> dict[str, Any]:
"""
Get information about the repository.
Returns:
Dictionary containing repository information
"""
url: Final = f"{self.base_url}/repositories/{self.workspace}/{self.repository}"
try:
response: Final = self.http_handler.get(url, headers=self.headers)
response.raise_for_status()
return response.json()
except Exception as e:
raise Exception(f"Failed to get repository info: {e}")
def test_connection(self) -> bool:
"""
Test the connection to the BitBucket repository.
Returns:
True if connection is successful, False otherwise
"""
try:
self.get_repository_info()
return True
except Exception:
return False
def get_branches(self) -> list[dict[str, Any]]:
"""
Get list of branches in the repository.
View on GitHub (pinned to 6c2dcb801b)
Solutions
- Use client.test_connection() first — it returns False instead of raising, letting you branch gracefully
- Check workspace and repository slugs exactly match the BitBucket URL (bitbucket.org/{workspace}/{repository})
- Confirm the token can read the repository via curl -H "Authorization: Bearer $TOKEN" https://api.bitbucket.org/2.0/repositories/{workspace}/{repo}
- Parse the embedded HTTP status from the message to distinguish auth (401/403) from not-found (404)
Example fix
# before
info = client.get_repository_info()
# after
if not client.test_connection():
raise RuntimeError(
f"Cannot reach BitBucket repo {client.workspace}/{client.repository}; "
"check slugs, token, and network egress"
)
info = client.get_repository_info() Defensive patterns
Strategy: try-catch
Validate before calling
if not client.test_connection():
raise RuntimeError("BitBucket repo unreachable; verify slugs, token, network") Try / catch
try:
info = client.get_repository_info()
except Exception as e:
msg = str(e)
if "401" in msg or "403" in msg:
fail_fast("credentials")
elif "404" in msg:
fail_fast("workspace/repository slug wrong")
else:
retry_or_alert(e) Prevention
- Run test_connection() in a startup readiness probe
- Keep workspace/repository slugs in one config source of truth
- Alert on repository rename/transfer events from BitBucket webhooks
When it happens
Trigger: Calling get_repository_info() or test_connection() with a wrong workspace/repository slug (404), bad credentials (401), insufficient repository read scope (403), or when network access to api.bitbucket.org fails before a response arrives.
Common situations: Initial setup validation of the BitBucket prompt integration; repository renamed or transferred to another workspace so the slug goes stale; typos in the workspace/repository config keys.
Related errors
- bitbucket_config is required for BitBucket prompt integratio
- workspace, repository, and access_token are required
- Failed to get branches: {e}
- Failed to load prompt '{prompt_id}' from BitBucket: {e}
- BitBucket configuration not found. Please set litellm.global
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/e847a81d77c8a626.
Report an issue: GitHub.