fix(vertexai,gateway): eliminate credential race conditions in multi-user deployments - #1017
Closed
Xibao-Lv wants to merge 6 commits into
Closed
fix(vertexai,gateway): eliminate credential race conditions in multi-user deployments#1017Xibao-Lv wants to merge 6 commits into
Xibao-Lv wants to merge 6 commits into
Conversation
added 5 commits
April 11, 2026 13:35
…nfig handling - Refactor VertexAI provider's _init_client to accept service_account, project, and location directly from configuration, eliminating dependency on system environment variables for credential propagation - Add _build_credentials method in GoogleProvider base class to handle service account credentials from JSON strings, file paths, or dictionaries - Simplify gateway's get_provider_kwargs function to return configuration directly without special VertexAI environment setup logic - Update docker/config.example.yml to use 'service_account' field instead of 'credentials' for consistency with new implementation - Remove setup_vertex_environment import and usage in gateway routes
… var dependency - Remove vertex_auth.py module and setup_vertex_environment function, which are no longer needed after switching to direct configuration handling - Delete associated test file test_vertex_credential_cleanup.py - Remove obsolete import of setup_vertex_environment in chat.py routes - Update docker/config.example.yml comments to reflect new configuration approach - Fix indentation in gemini/base.py to maintain consistent code style
… to credentials - Rename 'service_account' parameter to 'credentials' in VertexAI configuration and provider code for consistency with Google Cloud terminology - Update _build_credentials method signature to accept str | dict with proper type annotations - Fix docker/config.example.yml to use 'credentials' field instead of 'service_account' - Ensure error messages reference 'credentials' consistently
- Add clarifying comments for VertexAI configuration fields - Document that credentials accept file path, JSON string, or dict - Specify default GCP region as "us-central1" - Reflect architectural changes that removed environment variable dependency for thread-safe multi-user support
Member
|
Hi @Xibao-Lv , we are currently working on migrating the code of the gateway on a standalone repository. Would you mind reopening this PR on the new repository: https://github.com/mozilla-ai/gateway |
Contributor
Author
ok, i will reopen it later. |
Member
|
Thanks @Xibao-Lv , In the meantime I will close this PR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
This PR addresses a critical thread-safety issue in the Gateway's VertexAI provider implementation that caused credential mixing in multi-user scenarios. The original implementation used global environment variables
(GOOGLE_APPLICATION_CREDENTIALS, GOOGLE_CLOUD_PROJECT, GOOGLE_CLOUD_LOCATION) to pass credentials, creating race conditions when multiple users with different GCP configurations made concurrent requests.
The refactor eliminates environment variable dependency entirely by:
PR Type
Relevant issues
Fixes #1016 - VertexAI credential race conditions in multi-user Gateway deployments
Checklist
AI Usage Information
When answering questions by the reviewer, please respond yourself, do not copy/paste the reviewer comments into an AI system and paste back its answer. We want to discuss with you, not your AI :)
Changes Made
Core Changes
- Modified to accept credentials, project, location as direct parameters
- Builds isolated credential objects via _build_credentials()
- Eliminates environment variable dependency
- Added _build_credentials() to handle credential parsing from file paths, JSON strings, or dictionaries
- Returns isolated Credentials objects with required GCP scopes
- Simplified to return configuration directly without side effects
- Removed VertexAI-specific environment variable setup logic
Code Removal
- Removed setup_vertex_environment() function and temporary file management
- Eliminated global state and cleanup mechanisms
- Tests for removed functionality are no longer relevant
Configuration Updates
- Removed reference to deleted vertex_auth.py module
- Added clarification that credentials accepts file paths, JSON strings, or dictionaries
- Added clarifying comments for VertexAI configuration
- Documented that credentials accepts file paths, JSON strings, or dictionaries
- Updated to reflect new architectural approach
- Note: Configuration structure remains credentials, project, location at top level (not nested under client_args)
Technical Benefits
Configuration Impact
Users must update their configuration:
Files Changed: 7 files, 79 insertions(+), 200 deletions(-)
Commit History: 4 commits focusing on refactoring, cleanup, and documentation
Key Fix: Eliminates environment variable dependency that caused race conditions in multi-user Gateway deployments, ensuring each request uses isolated credentials specific to that user/configuration.