BerriAI/litellm · error · Exception

Error getting file metadata for

Error message

Error getting file metadata for '{file_path}': {e}

What it means

Raised by BitBucketClient.get_file_metadata when the exception has no HTTP status_code attribute — the request never completed at the HTTP layer. This is the connection-level branch: DNS failures, TCP refusals, TLS handshake errors, and timeouts from the shared HTTPHandler, distinct from sibling branch [303] which handles real HTTP responses.

Solutions

  1. Confirm basic reachability from the same host: curl -I "https://api.bitbucket.org/2.0/repositories/<ws>/<repo>/src/main/<file>" -H "Authorization: Bearer $TOKEN"
  2. Fix proxy/CA configuration (HTTPS_PROXY, SSL_CERT_FILE) when running in corporate networks
  3. Correct or remove the custom base_url in the client config
  4. Treat as transient: retry the metadata call with backoff before failing hard
Defensive patterns

Strategy: try-catch

Validate before calling

import httpx

def can_reach_bitbucket() -> bool:
    try:
        httpx.head("https://api.bitbucket.org/2.0", timeout=5.0)
        return True
    except httpx.RequestError:
        return False

Try / catch

try:
    meta = client.get_file_metadata(path)
except Exception as e:
    if str(e).startswith("Error getting file metadata"):
        ...  # connection-level: DNS/TLS/proxy — check env, then retry once
    else:
        raise

Prevention

When it happens

Trigger: Calling get_file_metadata when api.bitbucket.org (or a custom base_url) is unreachable: DNS resolution failure, firewall/proxy blocking egress, SSL verification error from corporate certificate inspection, or client timeout before a response arrives.

Common situations: Containers with broken DNS or no egress to api.bitbucket.org; corporate SSL-inspection proxies without a trusted CA in the container; wrong custom base_url for BitBucket Data Center deployments.

Related errors


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/aa1bde7648cc48e7. Report an issue: GitHub.

Appendix: source

Thrown at litellm/integrations/bitbucket/bitbucket_client.py:245

            headers: Final = self.headers.copy()
            headers["Range"] = "bytes=0-0"  # Request only first byte to get headers

            response: Final = self.http_handler.get(url, headers=headers)
            response.raise_for_status()

            return {
                "content_type": response.headers.get("content-type"),
                "content_length": response.headers.get("content-length"),
                "last_modified": response.headers.get("last-modified"),
            }
        except Exception as e:
            # Check if it's an HTTP error
            if hasattr(e, "response") and hasattr(e.response, "status_code"):
                if e.response.status_code == 404:
                    return None
                raise Exception(f"Failed to get file metadata for '{file_path}': {e}")
            else:
                raise Exception(f"Error getting file metadata for '{file_path}': {e}")

    def close(self):
        """Close the HTTP handler to free resources."""
        if hasattr(self, "http_handler"):
            self.http_handler.close()

View on GitHub (pinned to 77b7c6c40c)