Python: fix(google-ai): skip api_key check when use_vertexai is True#13607
Python: fix(google-ai): skip api_key check when use_vertexai is True#13607giulio-leone wants to merge 4 commits intomicrosoft:mainfrom
Conversation
|
@microsoft-github-policy-service agree |
27f8e4d to
ce250e0
Compare
|
Friendly ping — CI is green and this is ready for review. Happy to address any feedback. Thanks! |
ce250e0 to
3814db8
Compare
There was a problem hiding this comment.
Pull request overview
This PR fixes Google AI connector initialization for Vertex AI usage by skipping the api_key requirement when use_vertexai=True, aligning the validation logic with the intended ADC authentication path.
Changes:
- Guard
api_keyvalidation withnot use_vertexaiinGoogleAIChatCompletion. - Guard
api_keyvalidation withnot use_vertexaiinGoogleAITextCompletion. - Guard
api_keyvalidation withnot use_vertexaiinGoogleAITextEmbedding.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| python/semantic_kernel/connectors/ai/google/google_ai/services/google_ai_chat_completion.py | Skip API key validation when using Vertex AI during initialization. |
| python/semantic_kernel/connectors/ai/google/google_ai/services/google_ai_text_completion.py | Skip API key validation when using Vertex AI during initialization. |
| python/semantic_kernel/connectors/ai/google/google_ai/services/google_ai_text_embedding.py | Skip API key validation when using Vertex AI during initialization. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
python/semantic_kernel/connectors/ai/google/google_ai/services/google_ai_chat_completion.py
Show resolved
Hide resolved
python/semantic_kernel/connectors/ai/google/google_ai/services/google_ai_chat_completion.py
Show resolved
Hide resolved
python/semantic_kernel/connectors/ai/google/google_ai/services/google_ai_text_completion.py
Show resolved
Hide resolved
python/semantic_kernel/connectors/ai/google/google_ai/services/google_ai_text_embedding.py
Show resolved
Hide resolved
|
Hi! Gentle ping — this PR is rebased, CI passes, and ready for review. Happy to address any feedback. Thanks! |
d8cb434 to
56c3e4c
Compare
|
Friendly ping — CI is green, tests pass, ready for review whenever convenient. Happy to address any feedback. Thanks! 🙏 |
56c3e4c to
2bf8b08
Compare
|
Hi — all 4 threads resolved. cloud_region validation added to all 3 service classes. Fixes #13483. Ready for review! |
Head branch was pushed to by a user without write access
77e740d to
a6aa391
Compare
|
Rebased this branch onto current Local validation (Pass 1 and Pass 2)
Direct runtime proof (real source files, not mocks)Using the real
Results were identical across both proof passes:
So the rebased PR still fixes the original bug on all 3 Google AI service initializers while preserving the new |
a6aa391 to
083fafc
Compare
|
Just need the CI/CD checks to pass and we'll get this merged. We will monitor. |
083fafc to
8ba149c
Compare
|
Rebased this branch onto the current Local validation (Pass 1 and Pass 2)
Direct runtime proof against current
|
| Case | Chat | Text | Embedding |
|---|---|---|---|
current main + use_vertexai=True + no api_key |
ServiceInitializationError: The API key is required when use_vertexai is False. |
same | same |
rebased PR branch + use_vertexai=True + no api_key |
initializes successfully | initializes successfully | initializes successfully |
rebased PR branch + use_vertexai=True + missing cloud_region |
ServiceInitializationError: Region must be provided when use_vertexai is True. |
same | same |
So after rebasing onto the latest main, this PR still fixes the original Vertex AI initialization bug on all three Google AI service initializers while preserving the fast-fail cloud_region validation path.
|
Small status note on the refreshed head If that is just the usual maintainer approval step for fork workflows, that looks like the remaining blocker on the new head. If not, I am happy to investigate further from my side. |
8ba149c to
4d61d20
Compare
|
@giulio-leone please check the integration test errors: https://github.com/microsoft/semantic-kernel/actions/runs/23415605290/job/68110402458#step:9:16509 |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Follow-up for the integration-test feedback is now pushed on head Root cause: the branch had added the new Fix applied:
All three now require Validation from the refreshed head:
Direct proof of the exact integration trap (with
So this follow-up addresses the collaborator-reported integration failures without weakening the original |
|
@giulio-leone please make sure you have the pre-commit installed locally so all of these failures are caught before committing code to your branch and pushing upstream. There are ruff failures that need to be addressed. |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Addressed the latest pre-commit / ruff-format feedback on refreshed head This follow-up is formatter-only on the 3 integration selector files flagged by CI:
What changed:
Local verification on the updated head:
So the branch now includes the exact formatter normalization CI requested, while the previously pushed integration-selector fix and the original Vertex AI behavior fix remain unchanged. |
|
PR refresh — 2025-07-10 🤖 Validated on current main Test results (double pass ✅)
|
✅ Autonomous Validation — Pass 2/2 CleanBranch: Test Results (double-pass, no code changes between passes)
Runner: Fix VerificationGoogle AI services skip Validated autonomously — double-pass strict protocol (identical runs, no edits between passes) |
Summary
Fixes #13483
Motivation and Context
When
use_vertexai=True, users authenticate via Application Default Credentials (ADC) and don't need an API key. However, the initialization check forapi_keyruns unconditionally, blocking Vertex AI users with:Description
Guard the
api_keyvalidation withnot google_ai_settings.use_vertexaiin all three Google AI service classes:GoogleAIChatCompletionGoogleAITextCompletionGoogleAITextEmbeddingThe error message already reads "when use_vertexai is False", so the condition now matches the intent.
Before / After
Contribution Checklist