Skip to content

Python: Fix GoogleAI validation: skip API key check when using Vertex AI - #13518

Closed
veeceey wants to merge 3 commits into
microsoft:mainfrom
veeceey:fix/issue-13483-googleai-vertex-validation
Closed

Python: Fix GoogleAI validation: skip API key check when using Vertex AI#13518
veeceey wants to merge 3 commits into
microsoft:mainfrom
veeceey:fix/issue-13483-googleai-vertex-validation

Conversation

@veeceey

@veeceey veeceey commented Feb 7, 2026

Copy link
Copy Markdown

Summary

Fixes #13483 - GoogleAIChatCompletion now correctly skips API key validation when use_vertexai=True.

Changes

  • Updated API key validation in GoogleAIChatCompletion constructor to only require api_key when use_vertexai is False
  • Added unit test to verify initialization succeeds with Vertex AI mode without an API key

Test Plan

  • Added test_google_ai_chat_completion_init_with_vertexai_without_api_key to verify the fix
  • Existing tests ensure API key is still required when use_vertexai=False
  • Existing tests ensure project ID is required when use_vertexai=True

The validation logic now correctly differentiates between:

  • Vertex AI mode (use_vertexai=True): Requires project_id, API key is optional (uses ADC)
  • Standard mode (use_vertexai=False): Requires api_key

@veeceey
veeceey requested a review from a team as a code owner February 7, 2026 23:25
@moonbox3 moonbox3 added the python Pull requests for the Python Semantic Kernel label Feb 7, 2026
@github-actions github-actions Bot changed the title Fix GoogleAI validation: skip API key check when using Vertex AI Python: Fix GoogleAI validation: skip API key check when using Vertex AI Feb 7, 2026
@veeceey

veeceey commented Feb 10, 2026

Copy link
Copy Markdown
Author

Hi team -- friendly ping! This PR has been open for a couple of days without review. Would love any feedback when you get a chance. Thanks!

@moonbox3

Copy link
Copy Markdown
Collaborator

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
connectors/ai/google/google_ai/services
   google_ai_chat_completion.py1431390%113–114, 147, 151, 168, 173, 189, 193, 215, 220–221, 236, 238
TOTAL28147482182% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
3834 23 💤 0 ❌ 0 🔥 1m 46s ⏱️

@eavanvalkenburg

Copy link
Copy Markdown
Member

@veeceey there is a check failure, too long line in the new test, please fix!

@veeceey

veeceey commented Feb 11, 2026

Copy link
Copy Markdown
Author

Fixed! The long line in the test has been wrapped to comply with the line length limit. See commit f7edfe4. All tests pass and ruff is clean. Thanks for catching that!

@PrathamAditya

Copy link
Copy Markdown
Contributor

@veeceey , I have already created the PR for this 😂, just a little update was needed from my side.

@veeceey

veeceey commented Feb 14, 2026

Copy link
Copy Markdown
Author

Hey @PrathamAditya, sorry about the overlap! I didn't see a PR for this when I started. If yours is further along or the maintainers prefer it, happy to close mine. @eavanvalkenburg let me know which one you'd like to go with!

@PrathamAditya

Copy link
Copy Markdown
Contributor

@veeceey No problem! Looking forward to contribute together.

@veeceey

veeceey commented Feb 14, 2026

Copy link
Copy Markdown
Author

Hey @eavanvalkenburg, just checking in -- this PR is approved and CI is green. Could you merge when you get a chance? Happy to rebase if needed. Thanks!

@veeceey

veeceey commented Feb 16, 2026

Copy link
Copy Markdown
Author

Thanks for the approval! Is there anything else needed to get this merged?

@veeceey
veeceey force-pushed the fix/issue-13483-googleai-vertex-validation branch from bda70d9 to 8390854 Compare February 20, 2026 07:50
@veeceey
veeceey force-pushed the fix/issue-13483-googleai-vertex-validation branch 2 times, most recently from 41215c8 to b66f7f1 Compare March 12, 2026 01:25
@veeceey

veeceey commented Mar 12, 2026

Copy link
Copy Markdown
Author

Rebased on latest main to get up to date. CI should be green shortly. @eavanvalkenburg would be great to get this merged when you have a sec -- thanks!

@moonbox3

Copy link
Copy Markdown
Collaborator

CI may still fail. We're trying to get another PR in (MacOS runners are being super slow). Will get this in soon. Thanks for your patience.

@veeceey

veeceey commented Mar 13, 2026

Copy link
Copy Markdown
Author

thanks for the update! no rush at all, appreciate you keeping me in the loop.

@moonbox3
moonbox3 added this pull request to the merge queue Mar 13, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Mar 13, 2026
@veeceey
veeceey force-pushed the fix/issue-13483-googleai-vertex-validation branch from a506abf to 8176b81 Compare March 25, 2026 04:35
@veeceey

veeceey commented Mar 25, 2026

Copy link
Copy Markdown
Author

Rebased on latest main to resolve the merge conflict. Kept both the new cloud_region validation from upstream and our Vertex AI API key fix. CI should be running now.

@moonbox3

Copy link
Copy Markdown
Collaborator

@veeceey are we missing files? I only see a test file changed in the latest commits.

@moonbox3

moonbox3 commented Apr 8, 2026

Copy link
Copy Markdown
Collaborator

Hi @veeceey, this was fixed via #13607.

@moonbox3 moonbox3 closed this Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Pull requests for the Python Semantic Kernel

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: Bug: GoogleAIChatCompletion wrongly requires api_key even when use_vertexai is set to True

4 participants