BerriAI/litellm · error · OSError
Failed to read private key file
Error message
Failed to read private key file '{file_path}': {e} What it means
Error "Failed to read private key file '{file_path}': {e}" thrown in BerriAI/litellm.
Solutions
- Fix filesystem permissions on the key file shown in the message and ensure it is readable; see the wrapped error {e}.
When it happens
Trigger: Thrown at litellm/llms/oci/common_utils.py:135 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/16cf43eec1b87301.
Report an issue: GitHub.
Appendix: source
Thrown at litellm/llms/oci/common_utils.py:135
_require_cryptography()
key: Final = serialization.load_pem_private_key(
key_str.encode("utf-8"),
password=None,
)
if not isinstance(key, rsa.RSAPrivateKey):
raise TypeError("The provided private key is not an RSA key, which is required for OCI signing.")
return key
def load_private_key_from_file(file_path: str) -> Any:
"""Loads a private key from a file path."""
try:
with open(file_path, "r", encoding="utf-8") as f:
key_str: Final = f.read().strip()
except FileNotFoundError:
raise FileNotFoundError(f"Private key file not found: {file_path}")
except OSError as e:
raise OSError(f"Failed to read private key file '{file_path}': {e}") from e
if not key_str:
raise ValueError(f"Private key file is empty: {file_path}")
return load_private_key_from_str(key_str)
# ---------------------------------------------------------------------------
# Env-var credential resolution
# ---------------------------------------------------------------------------
_OCI_REGION_ENV: Final = "OCI_REGION"
_OCI_USER_ENV: Final = "OCI_USER"
_OCI_FINGERPRINT_ENV: Final = "OCI_FINGERPRINT"
_OCI_TENANCY_ENV: Final = "OCI_TENANCY"
_OCI_KEY_FILE_ENV: Final = "OCI_KEY_FILE"
_OCI_KEY_ENV: Final = "OCI_KEY"
_OCI_COMPARTMENT_ID_ENV: Final = "OCI_COMPARTMENT_ID"View on GitHub (pinned to 77b7c6c40c)