{"record":{"id":"aa1bde7648cc48e7","repo":"BerriAI/litellm","slug":"error-getting-file-metadata-for-file-path-e","errorCode":null,"errorMessage":"Error getting file metadata for '{file_path}': {e}","messagePattern":"Error getting file metadata for '(.+?)': (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"litellm/integrations/bitbucket/bitbucket_client.py","lineNumber":245,"sourceCode":"            headers: Final = self.headers.copy()\n            headers[\"Range\"] = \"bytes=0-0\"  # Request only first byte to get headers\n\n            response: Final = self.http_handler.get(url, headers=headers)\n            response.raise_for_status()\n\n            return {\n                \"content_type\": response.headers.get(\"content-type\"),\n                \"content_length\": response.headers.get(\"content-length\"),\n                \"last_modified\": response.headers.get(\"last-modified\"),\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 None\n                raise Exception(f\"Failed to get file metadata for '{file_path}': {e}\")\n            else:\n                raise Exception(f\"Error getting file metadata for '{file_path}': {e}\")\n\n    def close(self):\n        \"\"\"Close the HTTP handler to free resources.\"\"\"\n        if hasattr(self, \"http_handler\"):\n            self.http_handler.close()\n","sourceCodeStart":227,"sourceCodeEnd":251,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/integrations/bitbucket/bitbucket_client.py#L227-L251","documentation":"Non-HTTP branch of get_file_metadata's error handler: the raised exception has no .response attribute, meaning the request never got a response or failed locally — DNS/connectivity errors, TLS failures, or an exception while reading response headers. The original error is preserved only as a string inside the message.","triggerScenarios":"Calling get_file_metadata() in an environment that cannot reach api.bitbucket.org (connection refused, DNS failure), a corporate proxy terminating the connection, or a client certificate/TLS handshake failure.","commonSituations":"LiteLLM proxy deployed in a locked-down Kubernetes cluster without egress rules for api.bitbucket.org; missing HTTPS_PROXY in corporate networks; transient network interruptions during scheduled metadata sync.","solutions":["Verify egress: curl -I https://api.bitbucket.org/2.0/user from the same container","Configure HTTPS_PROXY if a corporate proxy is required","Wrap calls in retry-with-backoff for transient connectivity drops","Treat metadata as optional — catch and return None so prompt loading can proceed on cached content"],"exampleFix":"# before\nmeta = client.get_file_metadata(path)\n\n# after (metadata is best-effort)\ntry:\n    meta = client.get_file_metadata(path)\nexcept Exception as e:\n    if not hasattr(getattr(e, \"__context__\", None), \"response\"):\n        logger.warning(\"BitBucket unreachable, skipping metadata refresh for %s\", path)\n        meta = None\n    else:\n        raise","handlingStrategy":"fallback","validationCode":"import socket\n\ndef can_reach_bitbucket() -> bool:\n    try:\n        socket.create_connection((\"api.bitbucket.org\", 443), timeout=3).close()\n        return True\n    except OSError:\n        return False","typeGuard":null,"tryCatchPattern":"try:\n    meta = client.get_file_metadata(path)\nexcept Exception as e:\n    ctx = getattr(e, \"__context__\", None)\n    if ctx is not None and hasattr(ctx, \"response\"):\n        raise  # HTTP error, different bucket\n    meta = None  # network blip — proceed without metadata","preventionTips":["Design callers so metadata absence never blocks prompt loading","Configure egress proxies/firewall rules for api.bitbucket.org in containers","Wrap in retry-with-jitter for transient drops"],"tags":["bitbucket","network","proxy","metadata"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}