BerriAI/litellm · error · Exception

Failed to get repository info: {e}

Error message

Failed to get repository info: {e}

What it means

Catch-all raised by GitLabClient.get_repository_info when the GET /projects/{id} call fails for any reason. Unlike other methods it has no per-status handling, so even 401/403/404 land here. The original exception text is embedded.

Source

Thrown at litellm/integrations/gitlab/gitlab_client.py:240

            if status == 404:
                return []
            if status == 403:
                raise Exception(
                    f"Access denied to directory '{directory_path}'. Check your GitLab permissions for project '{self.project}'."
                )
            if status == 401:
                raise Exception("Authentication failed. Check your GitLab token and auth_method.")
            raise Exception(f"Failed to list files in '{directory_path}': {e}")

    def get_repository_info(self) -> dict[str, Any]:
        """Get information about the project/repository."""
        url: Final = f"{self.base_url}/projects/{self._project_enc}"
        try:
            resp: Final = self.http_handler.get(url, headers=self.headers)
            resp.raise_for_status()
            return resp.json()
        except Exception as e:
            raise Exception(f"Failed to get repository info: {e}")

    def test_connection(self) -> bool:
        """Test the connection to the GitLab project."""
        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."""
        url: Final = f"{self.base_url}/projects/{self._project_enc}/repository/branches"
        try:
            resp: Final = self.http_handler.get(url, headers=self.headers)
            resp.raise_for_status()
            data: Final = resp.json()
            return data if isinstance(data, list) else []
        except Exception as e:

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. Inspect the embedded exception for the real status code
  2. Verify the project identifier uses the full 'namespace/project' path
  3. Confirm base_url and token; a quick curl GET {base_url}/projects/{enc}?PRIVATE-TOKEN=... reproduces it
  4. Use test_connection() during setup to fail fast with logging enabled
Defensive patterns

Strategy: try-catch

Validate before calling

from urllib.parse import quote

def valid_project_id(project: str) -> bool:
    return bool(project) and "/" in project  # namespace/project form

Try / catch

try:
    info = client.get_repository_info()
except Exception as e:
    if not client.test_connection():
        # surface config problem early with clear message
        raise RuntimeError(f"GitLab config invalid: {e}") from e
    raise

Prevention

When it happens

Trigger: Calling get_repository_info() directly, or test_connection() swallowing it to return False, with an invalid project path (404), bad token (401), no access (403), wrong base_url, or network failure. Also raised if resp.json() fails on a non-JSON body.

Common situations: Project slug URL-encoding issues (e.g. 'group/sub/project' not encoded to group%2Fsub%2Fproject); wrong base_url; expired token; using test_connection() and wondering why it returns False — this exception is the hidden cause.

Related errors


AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15). Data as JSON: /api/errors/433154bacb8fc039. Report an issue: GitHub.