{"record":{"id":"433154bacb8fc039","repo":"BerriAI/litellm","slug":"failed-to-get-repository-info-e-433154","errorCode":null,"errorMessage":"Failed to get repository info: {e}","messagePattern":"Failed to get repository info: (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"litellm/integrations/gitlab/gitlab_client.py","lineNumber":240,"sourceCode":"            if status == 404:\n                return []\n            if status == 403:\n                raise Exception(\n                    f\"Access denied to directory '{directory_path}'. Check your GitLab permissions for project '{self.project}'.\"\n                )\n            if status == 401:\n                raise Exception(\"Authentication failed. Check your GitLab token and auth_method.\")\n            raise Exception(f\"Failed to list files in '{directory_path}': {e}\")\n\n    def get_repository_info(self) -> dict[str, Any]:\n        \"\"\"Get information about the project/repository.\"\"\"\n        url: Final = f\"{self.base_url}/projects/{self._project_enc}\"\n        try:\n            resp: Final = self.http_handler.get(url, headers=self.headers)\n            resp.raise_for_status()\n            return resp.json()\n        except Exception as e:\n            raise Exception(f\"Failed to get repository info: {e}\")\n\n    def test_connection(self) -> bool:\n        \"\"\"Test the connection to the GitLab project.\"\"\"\n        try:\n            self.get_repository_info()\n            return True\n        except Exception:\n            return False\n\n    def get_branches(self) -> list[dict[str, Any]]:\n        \"\"\"Get list of branches in the repository.\"\"\"\n        url: Final = f\"{self.base_url}/projects/{self._project_enc}/repository/branches\"\n        try:\n            resp: Final = self.http_handler.get(url, headers=self.headers)\n            resp.raise_for_status()\n            data: Final = resp.json()\n            return data if isinstance(data, list) else []\n        except Exception as e:","sourceCodeStart":222,"sourceCodeEnd":258,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/integrations/gitlab/gitlab_client.py#L222-L258","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Inspect the embedded exception for the real status code","Verify the project identifier uses the full 'namespace/project' path","Confirm base_url and token; a quick curl GET {base_url}/projects/{enc}?PRIVATE-TOKEN=... reproduces it","Use test_connection() during setup to fail fast with logging enabled"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"from urllib.parse import quote\n\ndef valid_project_id(project: str) -> bool:\n    return bool(project) and \"/\" in project  # namespace/project form","typeGuard":null,"tryCatchPattern":"try:\n    info = client.get_repository_info()\nexcept Exception as e:\n    if not client.test_connection():\n        # surface config problem early with clear message\n        raise RuntimeError(f\"GitLab config invalid: {e}\") from e\n    raise","preventionTips":["URL-encode 'group/project' as group%2Fproject when hand-building URLs","Call test_connection() at app startup and log failures","Keep base_url pointing at the API root (…/api/v4)"],"tags":["gitlab","http","api-client","diagnostics"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}