-
Notifications
You must be signed in to change notification settings - Fork 2k
Description
Describe the bug
When initializing ApplicationIntegrationToolset with an OAuth configuration, the application fails with a pydantic_core._pydantic_core.ValidationError. This appears to be caused by an internal incompatibility between google-adk and recent versions of pydantic (>=2.11).
The traceback indicates that the ADK's OpenApiSpecParser attempts to create a Schema(type='Any'), which is no longer a valid type literal in stricter, newer versions of Pydantic, leading to a validation failure during tool initialization.
Error message:
pydantic_core._pydantic_core.ValidationError: 2 validation errors for Schema
type.literal['array','boolean','integer','null','number','object','string']
Input should be 'array', 'boolean', 'integer', 'null', 'number', 'object' or 'string' [type=literal_error, input_value='Any', input_type=str]
For further information visit https://errors.pydantic.dev/2.11/v/literal_error
type.list[literal['array','boolean','integer','null','number','object','string']]
Input should be a valid list [type=list_type, input_value='Any', input_type=str]
Steps to reproduce the behavior:
1.Create a SharePoint connector in the Google Cloud Console (Integration Connectors). Configure the authentication to use AzureAD and provide the necessary client_id and client_secret.
2.Complete Azure authentication for the connector. Ensure the connection's status is Active.
3.Run the reproduction code that attempts to initialize the ApplicationIntegrationToolset with connector's details.
To Reproduce
File: reproduce_bug.py
from google.adk.tools.application_integration_tool.application_integration_toolset import ApplicationIntegrationToolset
from google.adk.tools.openapi_tool.auth.auth_helpers import dict_to_auth_scheme
from google.adk.auth import AuthCredential, AuthCredentialTypes, OAuth2Auth
Mocked OAuth2 data
oauth2_data_azure = {
"type": "oauth2",
"flows": {
"authorizationCode": {
"authorizationUrl": "https://example.com/auth",
"tokenUrl": "https://example.com/token",
"scopes": {"https://graph.microsoft.com/Sites.Read.All": "Read all sites"},
}
},
}
oauth_scheme = dict_to_auth_scheme(oauth2_data_azure)
auth_credential = AuthCredential(
auth_type=AuthCredentialTypes.OAUTH2,
oauth2=OAuth2Auth(client_id="mock_id", client_secret="mock_secret"),
)
This initialization triggers the error
try:
connector_tool = ApplicationIntegrationToolset(
project="project_id",
location="australia-southeast1",
connection="gcp-azure-sharepoint-connection",
actions=["SharePoint_files/GET_file_content_by_path"],
auth_scheme=oauth_scheme,
auth_credential=auth_credential
)
print("Initialization successful.")
except Exception as e:
print("Initialization failed.")
raise e
4.Observe pydantic validation error in the traceback. The error will point to the OpenApiSpecParser and an invalid schema type ('Any')
The script will fail with the following stack trace:
pydantic_core._pydantic_core.ValidationError: 2 validation errors for Schema
type.literal['array','boolean','integer','null','number','object','string']
Input should be 'array', 'boolean', 'integer', 'null', 'number', 'object' or 'string' [type=literal_error, input_value='Any', input_type=str]
For further information visit https://errors.pydantic.dev/2.11/v/literal_error
type.list[literal['array','boolean','integer','null','number','object','string']]
Input should be a valid list [type=list_type, input_value='Any', input_type=str]
Expected behavior
The ApplicationIntegrationToolset should initialize successfully without raising a ValidationError, correctly parsing the API specification even when newer versions of pydantic are installed.
Desktop (please complete the following information):
- OS: macOS
- Python version(python -V): Python 3.12.8
- ADK version(pip show google-adk): 1.6.1
Model Information:
- Are you using LiteLLM: No
- Which model is being used:gemini-2.5-flash
Additional context
This issue appears to be a dependency conflict where google-adk has not been updated to be compatible with breaking changes in recent pydantic v2 releases (specifically v2.11+). Other libraries, such as google-cloud-aiplatform, often require these newer pydantic versions, making it difficult to simply downgrade pydantic as a workaround.
Thank you for looking into this!