Skip to content

fix: resolve unexpected keyword arguments in test tool provider constructors#33242

Open
warren830 wants to merge 1 commit intolanggenius:mainfrom
warren830:fix/issue-32592-v2
Open

fix: resolve unexpected keyword arguments in test tool provider constructors#33242
warren830 wants to merge 1 commit intolanggenius:mainfrom
warren830:fix/issue-32592-v2

Conversation

@warren830
Copy link
Copy Markdown
Contributor

Description

Fixes #32592

The test helper _create_test_tool_provider in test_tools_transform_service.py was passing keyword arguments that don't exist as __init__ parameters on the MappedAsDataclass models.

Changes

ApiToolProvider:

  • Removed icon_dark (no such column)
  • Replaced credentials dict with credentials_str JSON string (matching the actual column)
  • Removed provider_type (not a constructor parameter)
  • Added required schema, schema_type_str, tools_str fields

BuiltinToolProvider:

  • Removed description, icon, icon_dark (these are either properties or non-existent columns)
  • Replaced credentials with encrypted_credentials (matching the actual column)
  • Added required user_id field

WorkflowToolProvider:

  • Removed icon_dark (no such column)
  • Replaced workflow_id with app_id (matching the actual column)
  • Added required label field

MCPToolProvider:

  • Removed description (no such column)
  • Replaced provider_icon with icon (matching the actual column)
  • Added required server_url_hash field

Also added import json for json.dumps usage in serializing credential dicts.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • Refactoring / chore

…est tool provider constructors

The test helper _create_test_tool_provider was passing keyword arguments
that don't exist as __init__ parameters on the MappedAsDataclass models:

- ApiToolProvider: removed icon_dark (no such column), replaced credentials
  dict with credentials_str JSON string, removed provider_type, added
  required schema/schema_type_str/tools_str fields
- BuiltinToolProvider: removed description/icon/icon_dark (properties or
  non-existent), replaced credentials with encrypted_credentials, added
  required user_id field
- WorkflowToolProvider: removed icon_dark (no such column), replaced
  workflow_id with app_id, added required label field
- MCPToolProvider: removed description (no such column), replaced
  provider_icon with icon, added required server_url_hash field

Also added import json for json.dumps usage.
@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Mar 11, 2026
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves an issue where a test helper function was attempting to initialize various ToolProvider models with incorrect or non-existent keyword arguments. The changes update the test helper to accurately reflect the constructor parameters of ApiToolProvider, BuiltinToolProvider, WorkflowToolProvider, and MCPToolProvider, ensuring that test instances are created correctly according to their model definitions.

Highlights

  • ApiToolProvider Constructor: Removed icon_dark and provider_type arguments, replaced credentials with credentials_str (JSON string), and added required schema, schema_type_str, and tools_str fields.
  • BuiltinToolProvider Constructor: Removed description, icon, and icon_dark arguments, replaced credentials with encrypted_credentials, and added the required user_id field.
  • WorkflowToolProvider Constructor: Removed icon_dark argument, replaced workflow_id with app_id, and added the required label field.
  • MCPToolProvider Constructor: Removed description argument, replaced provider_icon with icon, and added the required server_url_hash field.
  • JSON Import: Added an import for the json module to support json.dumps usage for serializing credential dictionaries.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • api/tests/test_containers_integration_tests/services/tools/test_tools_transform_service.py
    • Imported the json module.
    • Modified the _create_test_tool_provider helper function to use correct constructor arguments for ApiToolProvider, BuiltinToolProvider, WorkflowToolProvider, and MCPToolProvider instances.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly fixes issues with unexpected keyword arguments in test tool provider constructors by aligning the test data with the model definitions. The changes are accurate and address the problem described. I have one suggestion to improve the robustness of the test data for MCPToolProvider by dynamically calculating the server_url_hash instead of using a hardcoded string. This will make the test data more realistic and prevent potential conflicts.

@@ -1,3 +1,4 @@
import json
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To correctly calculate the server_url_hash for the MCPToolProvider test data, you'll need the hashlib module. Please import it here, keeping the standard library imports alphabetized.

Suggested change
import json
import hashlib
import json

Comment on lines 76 to 86
elif provider_type == "mcp":
provider = MCPToolProvider(
name=fake.company(),
description=fake.text(max_nb_chars=100),
provider_icon='{"background": "#FF6B6B", "content": "🔧"}',
icon='{"background": "#FF6B6B", "content": "🔧"}',
tenant_id="test_tenant_id",
user_id="test_user_id",
server_url="https://mcp.example.com",
server_url_hash="test_server_url_hash",
server_identifier="test_server",
tools='[{"name": "test_tool", "description": "Test tool"}]',
authed=True,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The server_url_hash should be derived from server_url to make the test data more realistic and robust. Using a hardcoded string can lead to test fragility. This suggestion refactors the MCPToolProvider instantiation to calculate the SHA256 hash from the URL, which is a better practice for test data generation.

Suggested change
elif provider_type == "mcp":
provider = MCPToolProvider(
name=fake.company(),
description=fake.text(max_nb_chars=100),
provider_icon='{"background": "#FF6B6B", "content": "🔧"}',
icon='{"background": "#FF6B6B", "content": "🔧"}',
tenant_id="test_tenant_id",
user_id="test_user_id",
server_url="https://mcp.example.com",
server_url_hash="test_server_url_hash",
server_identifier="test_server",
tools='[{"name": "test_tool", "description": "Test tool"}]',
authed=True,
elif provider_type == "mcp":
server_url = "https://mcp.example.com"
provider = MCPToolProvider(
name=fake.company(),
icon='{"background": "#FF6B6B", "content": "🔧"}',
tenant_id="test_tenant_id",
user_id="test_user_id",
server_url=server_url,
server_url_hash=hashlib.sha256(server_url.encode('utf-8')).hexdigest(),
server_identifier="test_server",
tools='[{"name": "test_tool", "description": "Test tool"}]',
authed=True,
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Refactor/Chore] ERROR Unexpected keyword argument

1 participant