diff --git a/src/openai/auth/_workload.py b/src/openai/auth/_workload.py index 6c142a82ed..c648d457d0 100644 --- a/src/openai/auth/_workload.py +++ b/src/openai/auth/_workload.py @@ -54,7 +54,7 @@ def k8s_service_account_token_provider( def get_token() -> str: try: - with open(token_file_path, "r") as f: + with open(token_file_path, "r", encoding="utf-8") as f: token = f.read().strip() if not token: raise SubjectTokenProviderError(f"The token file at {token_file_path} is empty.") diff --git a/tests/test_auth.py b/tests/test_auth.py index 17e9cd814c..3d99afb851 100644 --- a/tests/test_auth.py +++ b/tests/test_auth.py @@ -154,7 +154,7 @@ def test_workload_identity_exchange_error() -> None: def test_k8s_service_account_token_provider(tmp_path: Path) -> None: token_file = tmp_path / "token" - token_file.write_text("my-k8s-token") + token_file.write_text("my-k8s-token", encoding="utf-8") provider = k8s_service_account_token_provider(token_file)