fix(google): reject ambiguous Gemini plugin names - #14407
Conversation
|
ZIFeIYUuuuuuu please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
1 similar comment
|
ZIFeIYUuuuuuu please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
There was a problem hiding this comment.
🟢 Approval recommended
The change is narrowly scoped to the provider boundary, uses a shared helper consistently across both connectors, and is covered by targeted unit tests.
Pull request overview
This PR fixes an ambiguity in the Google Gemini/Vertex AI connector tool-name encoding by rejecting plugin names that contain the Gemini separator ("__"), preventing silent mis-routing of function calls when plugin names collide with the connector’s plugin/function join format.
Changes:
- Added a shared validation helper to reject plugin names containing the Gemini
"__"separator. - Invoked that validation before emitting function declarations for both Google AI and Vertex AI connectors.
- Added unit tests in both connector test suites to cover the ambiguous plugin-name rejection case.
File summaries
| File | Description |
|---|---|
| python/semantic_kernel/connectors/ai/google/shared_utils.py | Adds validate_gemini_plugin_name() to reject plugin names containing "__". |
| python/semantic_kernel/connectors/ai/google/google_ai/services/utils.py | Calls shared validation before formatting Google AI function declarations. |
| python/semantic_kernel/connectors/ai/google/vertex_ai/services/utils.py | Calls shared validation before formatting Vertex AI function declarations. |
| python/tests/unit/connectors/ai/google/google_ai/services/test_google_ai_utils.py | Adds a test asserting ambiguous plugin names are rejected with ServiceInvalidRequestError. |
| python/tests/unit/connectors/ai/google/vertex_ai/services/test_vertex_ai_utils.py | Adds a corresponding Vertex AI test for ambiguous plugin name rejection. |
Review details
- Files reviewed: 5/5 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
MAF Automated Review — Iteration 1
Result: Findings reported
Scope: full PR (1 commit(s)): 4d29aa6524d2
Model: gpt-5.6-sol-fast
Overview
The PR centralizes plugin-name validation and applies it before both Google AI and Vertex AI function declarations, with provider-specific tests covering names that directly contain __. Those guards preserve the existing wire format and reject the reported collision early. However, the validation misses plugin names ending in a single underscore, which overlap with the leading underscore of the separator and still decode to the wrong function identity.
Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
1 verified finding remained after source verification (1 medium) across 1 file. Details are attached to the affected lines below.
Affected areas: python/semantic_kernel/connectors/ai/google/shared_utils.py
|
|
||
| def validate_gemini_plugin_name(plugin_name: str | None) -> None: | ||
| """Reject plugin names that collide with Gemini's function-name separator.""" | ||
| if plugin_name and GEMINI_FUNCTION_NAME_SEPARATOR in plugin_name: |
There was a problem hiding this comment.
This still accepts a plugin name ending in a single underscore. For example, plugin_name="utils_" and name="time" encode as utils___time, which the existing first-__ decoder reads as plugin utils and function _time; auto-invocation can therefore route to the wrong function identity. Please also reject names whose suffix overlaps the separator (for __, names ending in _), or otherwise validate that the encoded name round-trips to the original pair.
|
Addressed the automated review finding in commit Gemini function names are encoded as Validation: the focused Google AI and Vertex AI utility suites pass (45 tests total), Ruff passes on the changed files, and |
|
@microsoft-github-policy-service agree |
Motivation / Context
The Gemini and Vertex AI connectors encode a plugin/function pair using
__because Gemini function names do not handle the kernel's default-separator reliably. Both plugin names and function names may legally contain underscores, so a plugin such asutils__getand a functiontimeare encoded asutils__get__time. The reverse conversion splits at the first__, making this name ambiguous and allowing the wrong function to be selected silently.Description
Add a shared connector validation helper and invoke it before formatting function declarations for both Google AI and Vertex AI. Plugin names containing the Gemini separator are rejected with
ServiceInvalidRequestError, including the conflicting plugin name and an explanation that it cannot be represented safely. Existing valid plugin/function names and the wire encoding remain unchanged.This keeps the fix at the provider boundary and avoids changing persisted or on-wire function-name formats.
Related issue number
Closes #14399
Tests
Validation:
uv run --group dev --extra google pytest tests/unit/connectors/ai/google/google_ai/services/test_google_ai_utils.py tests/unit/connectors/ai/google/vertex_ai/services/test_vertex_ai_utils.py tests/unit/connectors/ai/google/test_shared_utils.py -q— 40 passed.uv run --group dev ruff format --check ...— all files already formatted.uv run --group dev ruff check ...— all checks passed.git diff --check— passed.Checklist