Skip to content

fix(tests): correct keyword arguments in tool provider test constructors#33767

Merged
asukaminato0721 merged 1 commit intolanggenius:mainfrom
xr843:fix/test-tool-provider-keyword-args
Mar 19, 2026
Merged

fix(tests): correct keyword arguments in tool provider test constructors#33767
asukaminato0721 merged 1 commit intolanggenius:mainfrom
xr843:fix/test-tool-provider-keyword-args

Conversation

@xr843
Copy link
Copy Markdown
Contributor

@xr843 xr843 commented Mar 19, 2026

Important

  1. Make sure you have read our contribution guidelines
  2. Ensure there is an associated issue and you have been assigned to it
  3. Use the correct syntax to link this PR: Fixes #<issue number>.

Summary

Fixes #32592

Fix unexpected keyword argument errors in the _create_test_tool_provider helper method in test_tools_transform_service.py by aligning constructor arguments with the actual SQLAlchemy model definitions in api/models/tools.py.

Changes per provider:

  • ApiToolProvider: remove icon_dark and provider_type; rename credentials to credentials_str; add required schema, schema_type_str, tools_str
  • BuiltinToolProvider: remove description, icon, icon_dark; rename credentials to encrypted_credentials; add required user_id
  • WorkflowToolProvider: remove icon_dark; rename workflow_id to app_id; add required label, version, parameter_configuration
  • MCPToolProvider: remove description; rename provider_icon to icon; add required server_url_hash

The corrected field names are consistent with usage elsewhere in the test file (e.g., test_api_provider_to_controller_success at line 652) and in api/tests/unit_tests/models/test_tool_models.py.

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran make lint and make type-check (backend) and cd web && npx lint-staged (frontend) to appease the lint gods

Fix unexpected keyword argument errors in _create_test_tool_provider helper
by aligning constructor arguments with actual SQLAlchemy model definitions:

- ApiToolProvider: remove icon_dark and provider_type, rename credentials
  to credentials_str, add required schema/schema_type_str/tools_str
- BuiltinToolProvider: remove description/icon/icon_dark, rename credentials
  to encrypted_credentials, add required user_id
- WorkflowToolProvider: remove icon_dark, rename workflow_id to app_id,
  add required label/version/parameter_configuration
- MCPToolProvider: remove description, rename provider_icon to icon,
  add required server_url_hash

Closes langgenius#32592
@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Mar 19, 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 addresses keyword argument errors in the _create_test_tool_provider helper method within test_tools_transform_service.py. The changes ensure that the constructor arguments for various ToolProvider types (Api, Builtin, Workflow, MCP) in the test helper method accurately reflect the actual SQLAlchemy model definitions, resolving inconsistencies and improving test reliability.

Highlights

  • ApiToolProvider Constructor: Updated constructor arguments by removing 'icon_dark' and 'provider_type', renaming 'credentials' to 'credentials_str', and adding 'schema', 'schema_type_str', and 'tools_str'.
  • BuiltinToolProvider Constructor: Modified constructor arguments by removing 'description', 'icon', and 'icon_dark', renaming 'credentials' to 'encrypted_credentials', and adding 'user_id'.
  • WorkflowToolProvider Constructor: Adjusted constructor arguments by removing 'icon_dark', renaming 'workflow_id' to 'app_id', and adding 'label', 'version', and 'parameter_configuration'.
  • MCPToolProvider Constructor: Revised constructor arguments by removing 'description', renaming 'provider_icon' to 'icon', and adding 'server_url_hash'.

🧠 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.

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.

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 them with the model definitions. The changes are logical and address the problem described. I've added a few suggestions to improve the maintainability of the test code by using json.dumps for generating JSON strings instead of hardcoding them, which is less error-prone and more readable.

@github-actions
Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-03-19 14:11:32.254993005 +0000
+++ /tmp/pyrefly_pr.txt	2026-03-19 14:11:23.086861029 +0000
@@ -1417,28 +1417,6 @@
   --> tests/test_containers_integration_tests/services/tools/test_mcp_tools_manage_service.py:63:20
 ERROR Argument `Literal['normal']` is not assignable to parameter `status` with type `SQLCoreOperations[TenantStatus] | TenantStatus` in function `models.account.Tenant.__init__` [bad-argument-type]
   --> tests/test_containers_integration_tests/services/tools/test_mcp_tools_manage_service.py:72:20
-ERROR Unexpected keyword argument `icon_dark` in function `models.tools.ApiToolProvider.__init__` [unexpected-keyword]
-  --> tests/test_containers_integration_tests/services/tools/test_tools_transform_service.py:51:17
-ERROR Unexpected keyword argument `credentials` in function `models.tools.ApiToolProvider.__init__` [unexpected-keyword]
-  --> tests/test_containers_integration_tests/services/tools/test_tools_transform_service.py:54:17
-ERROR Unexpected keyword argument `provider_type` in function `models.tools.ApiToolProvider.__init__` [unexpected-keyword]
-  --> tests/test_containers_integration_tests/services/tools/test_tools_transform_service.py:55:17
-ERROR Unexpected keyword argument `description` in function `models.tools.BuiltinToolProvider.__init__` [unexpected-keyword]
-  --> tests/test_containers_integration_tests/services/tools/test_tools_transform_service.py:60:17
-ERROR Unexpected keyword argument `icon` in function `models.tools.BuiltinToolProvider.__init__` [unexpected-keyword]
-  --> tests/test_containers_integration_tests/services/tools/test_tools_transform_service.py:61:17
-ERROR Unexpected keyword argument `icon_dark` in function `models.tools.BuiltinToolProvider.__init__` [unexpected-keyword]
-  --> tests/test_containers_integration_tests/services/tools/test_tools_transform_service.py:62:17
-ERROR Unexpected keyword argument `credentials` in function `models.tools.BuiltinToolProvider.__init__` [unexpected-keyword]
-  --> tests/test_containers_integration_tests/services/tools/test_tools_transform_service.py:66:17
-ERROR Unexpected keyword argument `icon_dark` in function `models.tools.WorkflowToolProvider.__init__` [unexpected-keyword]
-  --> tests/test_containers_integration_tests/services/tools/test_tools_transform_service.py:73:17
-ERROR Unexpected keyword argument `workflow_id` in function `models.tools.WorkflowToolProvider.__init__` [unexpected-keyword]
-  --> tests/test_containers_integration_tests/services/tools/test_tools_transform_service.py:76:17
-ERROR Unexpected keyword argument `description` in function `models.tools.MCPToolProvider.__init__` [unexpected-keyword]
-  --> tests/test_containers_integration_tests/services/tools/test_tools_transform_service.py:81:17
-ERROR Unexpected keyword argument `provider_icon` in function `models.tools.MCPToolProvider.__init__` [unexpected-keyword]
-  --> tests/test_containers_integration_tests/services/tools/test_tools_transform_service.py:82:17
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
    --> tests/test_containers_integration_tests/services/tools/test_workflow_tools_manage_service.py:109:38
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Mar 19, 2026
@asukaminato0721 asukaminato0721 merged commit 7d19825 into langgenius:main Mar 19, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer 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

2 participants