From bc261fbce8e0acfd7580c581bf1660106a5c4c66 Mon Sep 17 00:00:00 2001 From: Kolade Fajimi <107228310+koladefaj@users.noreply.github.com> Date: Thu, 1 Oct 2026 18:36:38 +0100 Subject: [PATCH] refactor(vertex): read the failure's fields off the matched object CodeQL's py/uninitialized-local-variable does not follow keyword capture patterns in a match statement and reported `path` and `reason` as possibly unbound. Narrowing on the class and reading the attributes says the same thing without a suppression. --- litellm/llms/vertex_ai/credentials_source.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/litellm/llms/vertex_ai/credentials_source.py b/litellm/llms/vertex_ai/credentials_source.py index 4cbec1c5f1c..3f5001cd51a 100644 --- a/litellm/llms/vertex_ai/credentials_source.py +++ b/litellm/llms/vertex_ai/credentials_source.py @@ -125,21 +125,25 @@ def raise_vertex_credentials_failure(failure: VertexCredentialsFailure) -> NoRet a credential misconfigured into this field does not become a log entry. """ match failure: - case VertexCredentialsFileUnreadable(path=path, reason=reason): - verbose_logger.error("Vertex: cannot read the credentials file at %s: %s", redact_string(path), reason) + case VertexCredentialsFileUnreadable(): + verbose_logger.error( + "Vertex: cannot read the credentials file at %s: %s", redact_string(failure.path), failure.reason + ) raise ValueError( - f"Unable to read the vertex credentials file: {reason}. The proxy log names the path. " + f"Unable to read the vertex credentials file: {failure.reason}. The proxy log names the path. " "Set `vertex_credentials` to a readable file path, or to the credentials JSON itself." ) - case VertexCredentialsFileNotJson(path=path, detail=detail): - verbose_logger.error("Vertex: credentials file at %s is not valid JSON: %s", redact_string(path), detail) + case VertexCredentialsFileNotJson(): + verbose_logger.error( + "Vertex: credentials file at %s is not valid JSON: %s", redact_string(failure.path), failure.detail + ) raise ValueError( - f"The vertex credentials file is not valid JSON: {detail}. The proxy log names the path. " + f"The vertex credentials file is not valid JSON: {failure.detail}. The proxy log names the path. " "Check for unescaped newlines in private_key." ) - case VertexCredentialsInlineNotJson(detail=detail): + case VertexCredentialsInlineNotJson(): raise ValueError( - f"The inline `vertex_credentials` value is not valid JSON: {detail}. " + f"The inline `vertex_credentials` value is not valid JSON: {failure.detail}. " "Check for unescaped newlines in private_key." ) case _: # pragma: no cover - exhaustiveness guard, unreachable while the union holds