OpenApi 3.1.0 ArrayType is recognized as StringType unexpectly #4314

Closed
opened 2026-02-21 18:05:42 -05:00 by yindo · 5 comments
Owner

Originally created by @forrestsocool on GitHub (Jun 28, 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).
  • 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

0.6.11

Cloud or Self Hosted

Cloud

Steps to reproduce

Import this openapi schema as custom tool, add it into a workflow later, the "article_ids" parameter of ApiInsertArticleInsert is recognized as StringType instead of ArrayType[StringType ] (which Coze workflow can recognize correctly, though it only support 3.0.0 openApi schema, u can convert it ):

the openapi 3.1.0 schema generated by LiteStar

openapi (4).json

✔️ Expected Behavior

type of paramerter article_ids should be list[str]

Actual Behavior

type of paramerter article_ids is str

Originally created by @forrestsocool on GitHub (Jun 28, 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] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [X] Please do not modify this template :) and fill in all the required fields. ### Dify version 0.6.11 ### Cloud or Self Hosted Cloud ### Steps to reproduce Import this openapi schema as custom tool, add it into a workflow later, the "article_ids" parameter of ApiInsertArticleInsert is recognized as StringType instead of ArrayType[StringType ] (which Coze workflow can recognize correctly, though it only support 3.0.0 openApi schema, u can convert it ): the openapi 3.1.0 schema generated by LiteStar [openapi (4).json](https://github.com/user-attachments/files/16032615/openapi.4.json) ### ✔️ Expected Behavior type of paramerter article_ids should be list[str] ### ❌ Actual Behavior type of paramerter article_ids is str
yindo added the 💪 enhancement label 2026-02-21 18:05:42 -05:00
yindo closed this issue 2026-02-21 18:05:42 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Jun 28, 2024):

The issue with the article_ids parameter being recognized as StringType instead of ArrayType[StringType] in Dify version 0.6.11 is due to the _get_tool_parameter_type method in the ApiBasedToolSchemaParser class not handling array types. This method currently only checks for integer, number, boolean, and string types, and defaults to STRING for any other type.

Here is the relevant part of the code:

@staticmethod
def _get_tool_parameter_type(parameter: dict) -> ToolParameter.ToolParameterType:
    parameter = parameter or {}
    typ = None
    if 'type' in parameter:
        typ = parameter['type']
    elif 'schema' in parameter and 'type' in parameter['schema']:
        typ = parameter['schema']['type']
    
    if typ == 'integer' or typ == 'number':
        return ToolParameter.ToolParameterType.NUMBER
    elif typ == 'boolean':
        return ToolParameter.ToolParameterType.BOOLEAN
    elif typ == 'string':
        return ToolParameter.ToolParameterType.STRING

Since the method does not check for array type, it defaults to STRING. To fix this, you would need to modify the _get_tool_parameter_type method to handle array types appropriately [1].

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Jun 28, 2024): <!-- Answer --> The issue with the `article_ids` parameter being recognized as `StringType` instead of `ArrayType[StringType]` in Dify version 0.6.11 is due to the `_get_tool_parameter_type` method in the `ApiBasedToolSchemaParser` class not handling array types. This method currently only checks for `integer`, `number`, `boolean`, and `string` types, and defaults to `STRING` for any other type. Here is the relevant part of the code: ```python @staticmethod def _get_tool_parameter_type(parameter: dict) -> ToolParameter.ToolParameterType: parameter = parameter or {} typ = None if 'type' in parameter: typ = parameter['type'] elif 'schema' in parameter and 'type' in parameter['schema']: typ = parameter['schema']['type'] if typ == 'integer' or typ == 'number': return ToolParameter.ToolParameterType.NUMBER elif typ == 'boolean': return ToolParameter.ToolParameterType.BOOLEAN elif typ == 'string': return ToolParameter.ToolParameterType.STRING ``` Since the method does not check for `array` type, it defaults to `STRING`. To fix this, you would need to modify the `_get_tool_parameter_type` method to handle `array` types appropriately <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.*
Author
Owner

@laipz8200 commented on GitHub (Jul 1, 2024):

Our tool currently doesn't support array-type parameters, we might add this feature in the future.

@laipz8200 commented on GitHub (Jul 1, 2024): Our tool currently doesn't support array-type parameters, we might add this feature in the future.
Author
Owner

@qdaoming commented on GitHub (Jul 22, 2024):

Our tool currently doesn't support array-type parameters, we might add this feature in the future.

@laipz8200 This is an important missing feature. Do you know when it will be implemented?

@qdaoming commented on GitHub (Jul 22, 2024): > Our tool currently doesn't support array-type parameters, we might add this feature in the future. @laipz8200 This is an important missing feature. Do you know when it will be implemented?
Author
Owner

@laipz8200 commented on GitHub (Jul 27, 2024):

Our tool currently doesn't support array-type parameters, we might add this feature in the future.

@laipz8200 This is an important missing feature. Do you know when it will be implemented?

Since not all models have the capability to generate complex structured parameters, this feature is not a high priority for our team. However, you are welcome to try implementing it yourself.

@laipz8200 commented on GitHub (Jul 27, 2024): > > Our tool currently doesn't support array-type parameters, we might add this feature in the future. > > @laipz8200 This is an important missing feature. Do you know when it will be implemented? Since not all models have the capability to generate complex structured parameters, this feature is not a high priority for our team. However, you are welcome to try implementing it yourself.
Author
Owner

@qdaoming commented on GitHub (Aug 4, 2024):

Our tool currently doesn't support array-type parameters, we might add this feature in the future.

@laipz8200 This is an important missing feature. Do you know when it will be implemented?

Since not all models have the capability to generate complex structured parameters, this feature is not a high priority for our team. However, you are welcome to try implementing it yourself.

The input of tools can be from several sources, not only from LLM.
As said above, coze workflow works well for it.
If I can find available time, I might check this issue.

@qdaoming commented on GitHub (Aug 4, 2024): > > > Our tool currently doesn't support array-type parameters, we might add this feature in the future. > > > > > > @laipz8200 This is an important missing feature. Do you know when it will be implemented? > > Since not all models have the capability to generate complex structured parameters, this feature is not a high priority for our team. However, you are welcome to try implementing it yourself. The input of tools can be from several sources, not only from LLM. As said above, coze workflow works well for it. If I can find available time, I might check this issue.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#4314