From 596cc4c0c27d2079aef1ad3b72b9cdaef29e472c Mon Sep 17 00:00:00 2001 From: Kolade Fajimi <107228310+koladefaj@users.noreply.github.com> Date: Tue, 8 Sep 2026 07:20:45 +0100 Subject: [PATCH] refactor(vertex): log the credential source decision where it is made --- litellm/llms/vertex_ai/credentials_source.py | 9 +++++++-- litellm/llms/vertex_ai/vertex_llm_base.py | 7 ------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/litellm/llms/vertex_ai/credentials_source.py b/litellm/llms/vertex_ai/credentials_source.py index b59520d0fbe..a973d60d21c 100644 --- a/litellm/llms/vertex_ai/credentials_source.py +++ b/litellm/llms/vertex_ai/credentials_source.py @@ -6,6 +6,7 @@ it is decides what a failure means, so the two are told apart by the shape of th each failure is returned as its own case instead of collapsing into one parse error. """ +import os from collections.abc import Mapping from dataclasses import dataclass from typing import Final, NoReturn, TypeAlias @@ -80,7 +81,7 @@ def _read_json_file(path: str) -> _VertexCredentialsFile: return VertexCredentialsJson(parsed) -def is_inline_credentials_json(credentials: str) -> bool: +def _is_inline_credentials_json(credentials: str) -> bool: """Whether *credentials* carries the JSON itself rather than a path to a file holding it.""" return credentials.lstrip().startswith("{") @@ -92,7 +93,11 @@ def load_vertex_credentials_source(credentials: str) -> VertexCredentialsSource: failure recognisable: `os.path.exists()` answers False for an unreadable path as well as an absent one, so both used to reach the inline branch and be reported as malformed JSON. """ - if not is_inline_credentials_json(credentials): + inline_first: Final = _is_inline_credentials_json(credentials) + verbose_logger.debug( + "Vertex: Loading vertex credentials, is_file_path=%s, current dir %s", not inline_first, os.getcwd() + ) + if not inline_first: return _read_json_file(credentials) inline: Final = _parse_json_object(credentials) diff --git a/litellm/llms/vertex_ai/vertex_llm_base.py b/litellm/llms/vertex_ai/vertex_llm_base.py index eaddd3a9b58..e0886993109 100644 --- a/litellm/llms/vertex_ai/vertex_llm_base.py +++ b/litellm/llms/vertex_ai/vertex_llm_base.py @@ -6,7 +6,6 @@ Handles Authentication and generating request urls for Vertex AI and Google AI S import asyncio import json -import os import threading from collections.abc import Mapping from typing import TYPE_CHECKING, Any, Final, Literal, Protocol @@ -28,7 +27,6 @@ from .common_utils import ( ) from .credentials_source import ( VertexCredentialsJson, - is_inline_credentials_json, load_vertex_credentials_source, raise_vertex_credentials_failure, ) @@ -134,11 +132,6 @@ class VertexBase: if credentials is not None: if isinstance(credentials, str): source: Final = load_vertex_credentials_source(credentials) - verbose_logger.debug( - "Vertex: Loading vertex credentials, is_file_path=%s, current dir %s", - not is_inline_credentials_json(credentials), - os.getcwd(), - ) if not isinstance(source, VertexCredentialsJson): raise_vertex_credentials_failure(source) json_obj: Mapping[str, object] = source.value