BerriAI/litellm · error · Exception
Failed to get repository info
Error message
Failed to get repository info: {e} What it means
Raised by BitBucketClient.get_repository_info when ANY exception occurs during GET /repositories/{workspace}/{repository} — unlike list_files, this method has no per-status handling, so 404 (wrong workspace/repo slug), 401 (bad credentials), 403 (insufficient permissions), rate limits, and network errors are all flattened into one generic message. Note that test_connection() swallows this exception and returns False instead.
Solutions
- Call test_connection() first to get a boolean isolation of the problem, then get_repository_info() to see the wrapped cause
- If using an app password, set auth_method='basic' and username in the client config (app passwords do not work as Bearer tokens)
- Verify workspace and repository slugs by opening https://bitbucket.org/<workspace>/<repository>/repo/settings in a browser
- Regenerate/refresh the access token and confirm it has repository read scope
Example fix
// before
config = {"workspace": "acme", "repository": "prompts", "access_token": APP_PASSWORD}
// after
config = {
"workspace": "acme",
"repository": "prompts",
"access_token": APP_PASSWORD,
"auth_method": "basic",
"username": "dev@acme.com",
} Defensive patterns
Strategy: validation
Validate before calling
client = BitBucketClient(config)
if not client.test_connection():
raise RuntimeError(
"BitBucket unreachable/unauthorized: check workspace, repository, token, "
"and auth_method (app passwords need auth_method='basic' + username)"
) Try / catch
try:
info = client.get_repository_info()
except Exception as e:
# message flattens 401/403/404/network — re-fetch with curl to pinpoint
raise RuntimeError(f"repository info failed: {e}") from e Prevention
- Call test_connection() at startup and fail fast with a clear message
- Use auth_method='basic' plus username when authenticating with a BitBucket app password
- Store workspace/repository slugs exactly as they appear in the BitBucket URL
- Automate token rotation checks (curl /2.0/user) so expiry is caught before requests
When it happens
Trigger: Calling get_repository_info (or test_connection) with a workspace or repository slug that does not exist (404), a revoked or expired access token (401), a token whose scope excludes the repository (403), a renamed repository, or during a network-level failure.
Common situations: Using a BitBucket app password with the default auth_method='token' (Bearer header) instead of auth_method='basic' with a username; workspace UUID vs slug confusion; repository renamed after config was written; rotated tokens not updated in the LiteLLM proxy env.
Understand the failure class
Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.
Related errors
- Failed to get branches
- Failed to get file metadata for
- Authentication failed. Check your BitBucket access token…
- Error listing files in
- Access denied to directory
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/e847a81d77c8a626.
Report an issue: GitHub.
Appendix: 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 77b7c6c40c)