{"record":{"id":"7959d86c84ac9fed","repo":"BerriAI/litellm","slug":"error-listing-files-in-directory-path-e","errorCode":null,"errorMessage":"Error listing files in '{directory_path}': {e}","messagePattern":"Error listing files in '(.+?)': (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"litellm/integrations/bitbucket/bitbucket_client.py","lineNumber":163,"sourceCode":"                        files.append(file_path)\n\n            return files\n\n        except Exception as e:\n            # Check if it's an HTTP error\n            if hasattr(e, \"response\") and hasattr(e.response, \"status_code\"):\n                if e.response.status_code == 404:\n                    return []\n                elif e.response.status_code == 403:\n                    raise Exception(\n                        f\"Access denied to directory '{directory_path}'. Check your BitBucket permissions for workspace '{self.workspace}' and repository '{self.repository}'.\"\n                    )\n                elif e.response.status_code == 401:\n                    raise Exception(\"Authentication failed. Check your BitBucket access token and permissions.\")\n                else:\n                    raise Exception(f\"Failed to list files in '{directory_path}': {e}\")\n            else:\n                raise Exception(f\"Error listing files in '{directory_path}': {e}\")\n\n    def get_repository_info(self) -> dict[str, Any]:\n        \"\"\"\n        Get information about the repository.\n\n        Returns:\n            Dictionary containing repository information\n        \"\"\"\n        url: Final = f\"{self.base_url}/repositories/{self.workspace}/{self.repository}\"\n\n        try:\n            response: Final = self.http_handler.get(url, headers=self.headers)\n            response.raise_for_status()\n            return response.json()\n        except Exception as e:\n            raise Exception(f\"Failed to get repository info: {e}\")\n\n    def test_connection(self) -> bool:","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/integrations/bitbucket/bitbucket_client.py#L145-L181","documentation":"Raised by BitBucketClient.list_files_in_directory when the failure is not an HTTP response error at all — the exception has no .response attribute. Typical causes are network-layer failures (DNS resolution, connection refused, TLS errors) or bugs inside response.json() parsing (JSONDecodeError). It is the non-HTTP branch of the error handler, so the message wraps the raw exception string.","triggerScenarios":"The https_handler.get() call raising requests.exceptions.ConnectionError / DNSError before any response arrives, a proxy or firewall blocking api.bitbucket.org from the LiteLLM proxy pod, or a response body that is not valid JSON when the code parses pagination values.","commonSituations":"Running LiteLLM proxy in a container with no egress to api.bitbucket.org, corporate proxy environments where HTTPS_PROXY is unset, DNS misconfiguration in Kubernetes, or transient network drops during prompt sync.","solutions":["Test connectivity from the same host/container: curl -v https://api.bitbucket.org/2.0/workspaces","Set HTTPS_PROXY/HTTP_PROXY if the environment requires an egress proxy","Add retry with backoff for transient connection errors since this path has no automatic retry","If the message mentions JSON, inspect whether a proxy is returning an HTML error page instead of the BitBucket API"],"exampleFix":"# before\nfiles = client.list_files_in_directory(\"prompts\")\n\n# after (guard transient network failures)\nfrom requests.exceptions import ConnectionError as RequestsConnectionError\ntry:\n    files = client.list_files_in_directory(\"prompts\")\nexcept Exception as e:\n    if isinstance(e.__context__, RequestsConnectionError):\n        logger.warning(\"BitBucket unreachable, using cached prompt list\")\n        files = cached_files\n    else:\n        raise","handlingStrategy":"retry","validationCode":"import socket\n\ndef bitbucket_reachable(host: str = \"api.bitbucket.org\", timeout: float = 3.0) -> bool:\n    try:\n        socket.getaddrinfo(host, 443)\n        return True\n    except socket.gaierror:\n        return False","typeGuard":null,"tryCatchPattern":"try:\n    files = client.list_files_in_directory(\"prompts\")\nexcept Exception as e:\n    if hasattr(e, \"response\") or hasattr(getattr(e, \"__context__\", None), \"response\"):\n        raise  # HTTP-level error, see error 341\n    logger.warning(\"Network-level BitBucket failure: %s\", e)\n    files = cached_listing  # degrade gracefully","preventionTips":["Configure HTTPS_PROXY in corporate networks before deploying","Add DNS/egress health checks for api.bitbucket.org to your deployment probes","Keep a last-known-good listing on disk for degraded-mode operation"],"tags":["bitbucket","network","dns","proxy"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}