Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix loading env GOOGLE_APPLICATION_CREDENTIALS #13

Merged
merged 1 commit into from
Dec 15, 2024
Merged

Conversation

zaironjacobs
Copy link
Collaborator

Description

The type for GOOGLE_APPLICATION_CREDENTIALS was changed from dict to str | None in settings.py. Previously a crash would occur if the provided value is not a valid JSON or is empty. Now, an attempt to load the env variable as a dictionary is done in google_embeddings.py within a try-except block, when this is successful, the Google models will be loaded, else they are not available.

Fixes #12

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Testing

Tested the following to make sure the app does not crash:

  • Start app without the env GOOGLE_APPLICATION_CREDENTIALS.
  • Start app with an invalid JSON at GOOGLE_APPLICATION_CREDENTIALS.
  • Start app with a valid JSON at GOOGLE_APPLICATION_CREDENTIALS where the content does not contain the keys expected (the expected content is the content of credentials.json).

@woodthom2
Copy link
Contributor

Thanks @zaironjacobs !

@woodthom2 woodthom2 merged commit 5407710 into main Dec 15, 2024
1 check failed
@woodthom2 woodthom2 deleted the fix-env-google branch December 15, 2024 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Application crashes with invalid GOOGLE_APPLICATION_CREDENTIALS
2 participants