chore: Replace ValueError with logger.warning for missing GOOGLE_APPLICATION_CREDENTIALS environment variable #1415
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
According to the Google Auth library, authentication should be possible without the
GOOGLE_APPLICATION_CREDENTIALS
environment variable by using commands likegcloud auth application-default login
andgcloud config set project
. However, the current implementation does not support this, so this pull request addresses and fixes that issue by logging a warning instead of raising aValueError
when the environment variable is not set. This change ensures consistency with the existing implementation and allows the use of alternative Google authentication methods.Changes
ValueError
with alogger.warning
Related Information
By modifying the implementation to log a warning instead of raising an error, this pull request aligns the behavior with the intended flexibility of the Google Auth library (below). This allows applications to rely on other authentication methods seamlessly, enhancing compatibility with various deployment environments and configurations.
agents/livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/llm.py
Lines 224 to 228 in 489f786
https://github.com/googleapis/google-auth-library-python/blob/main/google/auth/_default.py#L577-L607