runtime error. fail to execute some functions due to function input params missing #6033

Closed
opened 2026-02-21 18:13:46 -05:00 by yindo · 1 comment
Owner

Originally created by @AkisAya on GitHub (Oct 11, 2024).

Originally assigned to: @laipz8200 on GitHub.

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

main

Cloud or Self Hosted

Self Hosted (Source)

Steps to reproduce

update existsing custom tools will throw an Exception, indicating that argument 'warning' is missing.
update tool config error

After reviewing the code, it's due to the missing of default None value when introducing Optional type to function params.
e.g.

## ApiToolManageService
    @staticmethod
    def convert_schema_to_tool_bundles(schema: str, extra_info: Optional[dict] = None) -> list[ApiToolBundle]:
        """
        convert schema to tool bundles

        :return: the list of tool bundles, description
        """
        try:
            tool_bundles = ApiBasedToolSchemaParser.auto_parse_to_tool_bundle(schema, extra_info=extra_info)
            return tool_bundles
        except Exception as e:
            raise ValueError(f"invalid schema: {str(e)}")

## ApiBasedToolSchemaParser
    def auto_parse_to_tool_bundle(
        content: str, extra_info: Optional[dict], warning: Optional[dict]
    ) -> tuple[list[ApiToolBundle], str]:

this change is is introduced by commit: https://github.com/langgenius/dify/commit/240b66d7373f11db378d5b3a67594e5ea1f2fc66

✔️ Expected Behavior

update tools successfully

Actual Behavior

fail to update tools

Originally created by @AkisAya on GitHub (Oct 11, 2024). Originally assigned to: @laipz8200 on GitHub. ### Self Checks - [X] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [X] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [X] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [X] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [X] Please do not modify this template :) and fill in all the required fields. ### Dify version main ### Cloud or Self Hosted Self Hosted (Source) ### Steps to reproduce update existsing custom tools will throw an Exception, indicating that argument 'warning' is missing. ![update tool config error](https://github.com/user-attachments/assets/f5b7f33a-ca1f-424c-a089-ed1ad375b59e) After reviewing the code, it's due to the missing of default None value when introducing Optional type to function params. e.g. ``` ## ApiToolManageService @staticmethod def convert_schema_to_tool_bundles(schema: str, extra_info: Optional[dict] = None) -> list[ApiToolBundle]: """ convert schema to tool bundles :return: the list of tool bundles, description """ try: tool_bundles = ApiBasedToolSchemaParser.auto_parse_to_tool_bundle(schema, extra_info=extra_info) return tool_bundles except Exception as e: raise ValueError(f"invalid schema: {str(e)}") ## ApiBasedToolSchemaParser def auto_parse_to_tool_bundle( content: str, extra_info: Optional[dict], warning: Optional[dict] ) -> tuple[list[ApiToolBundle], str]: ``` this change is is introduced by commit: https://github.com/langgenius/dify/commit/240b66d7373f11db378d5b3a67594e5ea1f2fc66 ### ✔️ Expected Behavior update tools successfully ### ❌ Actual Behavior fail to update tools
yindo added the 🐞 bug label 2026-02-21 18:13:46 -05:00
yindo closed this issue 2026-02-21 18:13:46 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Oct 11, 2024):

Hello, @AkisAya! I'm here to help you with bug fixes, answer your questions, and assist you in becoming a contributor. If you need any assistance, feel free to ask!

To resolve the runtime error caused by the missing 'warning' argument in the auto_parse_to_tool_bundle method, you need to provide a warning argument when calling the method. You can pass an empty dictionary if no warnings are needed. Here's how you can modify the convert_schema_to_tool_bundles method:

@staticmethod
def convert_schema_to_tool_bundles(schema: str, extra_info: Optional[dict] = None) -> list[ApiToolBundle]:
    """
    convert schema to tool bundles

    :return: the list of tool bundles, description
    """
    try:
        warnings = {}
        tool_bundles = ApiBasedToolSchemaParser.auto_parse_to_tool_bundle(schema, extra_info=extra_info, warning=warnings)
        return tool_bundles
    except Exception as e:
        raise ValueError(f"invalid schema: {str(e)}")

This ensures that the warning parameter is provided, preventing the runtime error [1].

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Oct 11, 2024): <!-- Greeting --> Hello, @AkisAya! I'm here to help you with bug fixes, answer your questions, and assist you in becoming a contributor. If you need any assistance, feel free to ask! <!-- Answer --> To resolve the runtime error caused by the missing 'warning' argument in the `auto_parse_to_tool_bundle` method, you need to provide a `warning` argument when calling the method. You can pass an empty dictionary if no warnings are needed. Here's how you can modify the `convert_schema_to_tool_bundles` method: ```python @staticmethod def convert_schema_to_tool_bundles(schema: str, extra_info: Optional[dict] = None) -> list[ApiToolBundle]: """ convert schema to tool bundles :return: the list of tool bundles, description """ try: warnings = {} tool_bundles = ApiBasedToolSchemaParser.auto_parse_to_tool_bundle(schema, extra_info=extra_info, warning=warnings) return tool_bundles except Exception as e: raise ValueError(f"invalid schema: {str(e)}") ``` This ensures that the `warning` parameter is provided, preventing the runtime error <sup>[[1]](https://github.com/langgenius/dify/blob/main/api/core/tools/utils/parser.py)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#6033