From 1a788a96a54dcc168df0d1e24bfbddd80d44e044 Mon Sep 17 00:00:00 2001 From: mateo Date: Sat, 19 Sep 2026 07:55:03 +0000 Subject: [PATCH] fix(chatgpt): normalize chatgpt_auth_file before caching the authenticator Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- litellm/llms/chatgpt/authenticator.py | 4 +++- .../llms/chatgpt/test_chatgpt_authenticator.py | 13 +++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/litellm/llms/chatgpt/authenticator.py b/litellm/llms/chatgpt/authenticator.py index 2c9790ed703..8af45c82bc6 100644 --- a/litellm/llms/chatgpt/authenticator.py +++ b/litellm/llms/chatgpt/authenticator.py @@ -54,7 +54,9 @@ def get_chatgpt_auth_file( if isinstance(litellm_params, Mapping) else litellm_params.chatgpt_auth_file ) - return value if isinstance(value, str) and value else None + if not isinstance(value, str) or not value: + return None + return os.path.abspath(os.path.expanduser(value)) @lru_cache(maxsize=128) diff --git a/tests/test_litellm/llms/chatgpt/test_chatgpt_authenticator.py b/tests/test_litellm/llms/chatgpt/test_chatgpt_authenticator.py index 213830af4a9..83114318950 100644 --- a/tests/test_litellm/llms/chatgpt/test_chatgpt_authenticator.py +++ b/tests/test_litellm/llms/chatgpt/test_chatgpt_authenticator.py @@ -147,6 +147,19 @@ class TestChatGPTMultiAccountAuthenticator: assert get_chatgpt_auth_file(GenericLiteLLMParams()) is None assert get_chatgpt_auth_file(GenericLiteLLMParams(chatgpt_auth_file="/b/auth.json")) == "/b/auth.json" + def test_relative_and_absolute_auth_file_share_cached_authenticator(self, tmp_path, monkeypatch): + monkeypatch.chdir(tmp_path) + get_cached_authenticator.cache_clear() + auth_file = tmp_path / "x" / "auth.json" + auth_file.parent.mkdir(parents=True) + auth_file.write_text("{}") + + relative_key = get_chatgpt_auth_file({"chatgpt_auth_file": "x/auth.json"}) + absolute_key = get_chatgpt_auth_file({"chatgpt_auth_file": str(auth_file)}) + assert relative_key is not None and absolute_key is not None + + assert get_cached_authenticator(relative_key) is get_cached_authenticator(absolute_key) + class TestChatGPTAuthFileEarlyProviderDetection: @staticmethod