Validation error occurs when using 'app-selector' as type of parameter for a tool. #13369

Closed
opened 2026-02-21 19:11:50 -05:00 by yindo · 1 comment
Owner

Originally created by @AAlexDing on GitHub (Apr 25, 2025).

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

1.3.0

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

When I tried to develop a tool. I used app-selector as the type of a parameter,then a validation error occurs.

identity:
  name: dify2dify
  author: dinggg
  label:
    en_US: dify2dify
    zh_Hans: dify2dify
description:
  human:
    en_US: Let exisiting app including chatflow/agent/chatbot used as a tool.
    zh_Hans: 将现有的app(chatflow/agent/chatbot)作为工具使用。
  llm: Let exisiting app including chatflow/agent/chatbot used as a tool.
parameters:
  - name: app
    type: app-selector
    scope: all
    required: false
    label:
      en_US: App
    placeholder:
      en_US: Please select an app
      zh_Hans: 请选择一个应用
    human_description:
      en_US: Select the Dify application you want to use as a tool
      zh_Hans: 选择要作为工具使用的 Dify 应用
    llm_description: select the Dify app you want to use as a tool
    form: llm
  - name: query
    type: string
    required: true
    label:
      en_US: User input
      zh_Hans: 用户输入
      pt_BR: Entrada do usuário
    human_description:
      en_US: user input
      zh_Hans: 用户输入
      pt_BR: Entrada do usuário
    llm_description: user input
    form: llm

extra:
  python:
    source: tools/dify2dify.py

bug report log:

2025-04-25 13:16:58.339 ERROR [Thread-133 (_generate_worker)] [graph_engine.py:215] - Unknown Error when graph running
Traceback (most recent call last):
  File "/app/api/core/workflow/graph_engine/graph_engine.py", line 166, in run
    for item in generator:
                ^^^^^^^^^
  File "/app/api/core/workflow/nodes/answer/answer_stream_processor.py", line 31, in process
    for event in generator:
                 ^^^^^^^^^
  File "/app/api/core/workflow/graph_engine/graph_engine.py", line 266, in _run
    node_instance = node_cls(  # type: ignore
                    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/api/core/workflow/nodes/base/node.py", line 59, in __init__
    node_data = self._node_data_cls.model_validate(config.get("data", {}))
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/api/.venv/lib/python3.12/site-packages/pydantic/main.py", line 596, in model_validate
    return cls.__pydantic_validator__.validate_python(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 2 validation errors for ToolNodeData
tool_parameters.app.value
  Field required [type=missing, input_value={'app_id': 'c6349687-7db1...nputs': {}, 'files': []}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.9/v/missing
tool_parameters.app.type
  Field required [type=missing, input_value={'app_id': 'c6349687-7db1...nputs': {}, 'files': []}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.9/v/missing
2025-04-25 13:16:58.342 ERROR [Thread-133 (_generate_worker)] [workflow_entry.py:108] - Unknown Error when workflow entry running
Traceback (most recent call last):
  File "/app/api/core/workflow/workflow_entry.py", line 100, in run
    for event in generator:
                 ^^^^^^^^^
  File "/app/api/core/workflow/graph_engine/graph_engine.py", line 218, in run
    raise e
  File "/app/api/core/workflow/graph_engine/graph_engine.py", line 166, in run
    for item in generator:
                ^^^^^^^^^
  File "/app/api/core/workflow/nodes/answer/answer_stream_processor.py", line 31, in process
    for event in generator:
                 ^^^^^^^^^
  File "/app/api/core/workflow/graph_engine/graph_engine.py", line 266, in _run
    node_instance = node_cls(  # type: ignore
                    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/api/core/workflow/nodes/base/node.py", line 59, in __init__
    node_data = self._node_data_cls.model_validate(config.get("data", {}))
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/api/.venv/lib/python3.12/site-packages/pydantic/main.py", line 596, in model_validate
    return cls.__pydantic_validator__.validate_python(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 2 validation errors for ToolNodeData
tool_parameters.app.value
  Field required [type=missing, input_value={'app_id': 'c6349687-7db1...nputs': {}, 'files': []}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.9/v/missing
tool_parameters.app.type
  Field required [type=missing, input_value={'app_id': 'c6349687-7db1...nputs': {}, 'files': []}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.9/v/missing
2025-04-25 13:16:58.699 DEBUG [Dummy-132] [based_generate_task_pipeline.py:45] - error: Run failed: 2 validation errors for ToolNodeData
tool_parameters.app.value
  Field required [type=missing, input_value={'app_id': 'c6349687-7db1...nputs': {}, 'files': []}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.9/v/missing
tool_parameters.app.type
  Field required [type=missing, input_value={'app_id': 'c6349687-7db1...nputs': {}, 'files': []}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.9/v/missing

Based on the error message and code analysis, I've found that the problem is with parameter validation in the Tool Node. Specifically:

The error shows missing two required fields:

tool_parameters.app.value
tool_parameters.app.type
From the code in entities.py, we can see that the tool_parameters in ToolNodeData needs to contain values of the ToolInput type, where each ToolInput must include:

value: which can be any value or a list of strings
type: which must be one of "mixed", "variable", or "constant"
The current data format being passed in:

{
    'app_id': 'c6349687-7db1...',
    'inputs': {},
    'files': []
}

This format is missing the required value and type fields for the app parameter.

✔️ Expected Behavior

get app_id of the selected app

Actual Behavior

Image

Originally created by @AAlexDing on GitHub (Apr 25, 2025). ### 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 1.3.0 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce When I tried to develop a tool. I used `app-selector` as the `type` of a parameter,then a validation error occurs. ``` identity: name: dify2dify author: dinggg label: en_US: dify2dify zh_Hans: dify2dify description: human: en_US: Let exisiting app including chatflow/agent/chatbot used as a tool. zh_Hans: 将现有的app(chatflow/agent/chatbot)作为工具使用。 llm: Let exisiting app including chatflow/agent/chatbot used as a tool. parameters: - name: app type: app-selector scope: all required: false label: en_US: App placeholder: en_US: Please select an app zh_Hans: 请选择一个应用 human_description: en_US: Select the Dify application you want to use as a tool zh_Hans: 选择要作为工具使用的 Dify 应用 llm_description: select the Dify app you want to use as a tool form: llm - name: query type: string required: true label: en_US: User input zh_Hans: 用户输入 pt_BR: Entrada do usuário human_description: en_US: user input zh_Hans: 用户输入 pt_BR: Entrada do usuário llm_description: user input form: llm extra: python: source: tools/dify2dify.py ``` bug report log: ``` 2025-04-25 13:16:58.339 ERROR [Thread-133 (_generate_worker)] [graph_engine.py:215] - Unknown Error when graph running Traceback (most recent call last): File "/app/api/core/workflow/graph_engine/graph_engine.py", line 166, in run for item in generator: ^^^^^^^^^ File "/app/api/core/workflow/nodes/answer/answer_stream_processor.py", line 31, in process for event in generator: ^^^^^^^^^ File "/app/api/core/workflow/graph_engine/graph_engine.py", line 266, in _run node_instance = node_cls( # type: ignore ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/core/workflow/nodes/base/node.py", line 59, in __init__ node_data = self._node_data_cls.model_validate(config.get("data", {})) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/pydantic/main.py", line 596, in model_validate return cls.__pydantic_validator__.validate_python( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pydantic_core._pydantic_core.ValidationError: 2 validation errors for ToolNodeData tool_parameters.app.value Field required [type=missing, input_value={'app_id': 'c6349687-7db1...nputs': {}, 'files': []}, input_type=dict] For further information visit https://errors.pydantic.dev/2.9/v/missing tool_parameters.app.type Field required [type=missing, input_value={'app_id': 'c6349687-7db1...nputs': {}, 'files': []}, input_type=dict] For further information visit https://errors.pydantic.dev/2.9/v/missing 2025-04-25 13:16:58.342 ERROR [Thread-133 (_generate_worker)] [workflow_entry.py:108] - Unknown Error when workflow entry running Traceback (most recent call last): File "/app/api/core/workflow/workflow_entry.py", line 100, in run for event in generator: ^^^^^^^^^ File "/app/api/core/workflow/graph_engine/graph_engine.py", line 218, in run raise e File "/app/api/core/workflow/graph_engine/graph_engine.py", line 166, in run for item in generator: ^^^^^^^^^ File "/app/api/core/workflow/nodes/answer/answer_stream_processor.py", line 31, in process for event in generator: ^^^^^^^^^ File "/app/api/core/workflow/graph_engine/graph_engine.py", line 266, in _run node_instance = node_cls( # type: ignore ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/core/workflow/nodes/base/node.py", line 59, in __init__ node_data = self._node_data_cls.model_validate(config.get("data", {})) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/pydantic/main.py", line 596, in model_validate return cls.__pydantic_validator__.validate_python( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pydantic_core._pydantic_core.ValidationError: 2 validation errors for ToolNodeData tool_parameters.app.value Field required [type=missing, input_value={'app_id': 'c6349687-7db1...nputs': {}, 'files': []}, input_type=dict] For further information visit https://errors.pydantic.dev/2.9/v/missing tool_parameters.app.type Field required [type=missing, input_value={'app_id': 'c6349687-7db1...nputs': {}, 'files': []}, input_type=dict] For further information visit https://errors.pydantic.dev/2.9/v/missing 2025-04-25 13:16:58.699 DEBUG [Dummy-132] [based_generate_task_pipeline.py:45] - error: Run failed: 2 validation errors for ToolNodeData tool_parameters.app.value Field required [type=missing, input_value={'app_id': 'c6349687-7db1...nputs': {}, 'files': []}, input_type=dict] For further information visit https://errors.pydantic.dev/2.9/v/missing tool_parameters.app.type Field required [type=missing, input_value={'app_id': 'c6349687-7db1...nputs': {}, 'files': []}, input_type=dict] For further information visit https://errors.pydantic.dev/2.9/v/missing ``` Based on the error message and code analysis, I've found that the problem is with parameter validation in the Tool Node. Specifically: The error shows missing two required fields: tool_parameters.app.value tool_parameters.app.type From the code in entities.py, we can see that the tool_parameters in ToolNodeData needs to contain values of the ToolInput type, where each ToolInput must include: value: which can be any value or a list of strings type: which must be one of "mixed", "variable", or "constant" The current data format being passed in: ``` { 'app_id': 'c6349687-7db1...', 'inputs': {}, 'files': [] } ``` This format is missing the required value and type fields for the app parameter. ### ✔️ Expected Behavior get app_id of the selected app ### ❌ Actual Behavior ![Image](https://github.com/user-attachments/assets/ef595bb0-a31f-4545-8831-a528ad51aef7)
yindo added the 🔨 feat:tools label 2026-02-21 19:11:50 -05:00
yindo closed this issue 2026-02-21 19:11:50 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Apr 25, 2025):

Hello @AAlexDing! I'm Dosu, your friendly bot here to help with bugs, answer questions, and guide you toward becoming a contributor! I'm ready to assist you while we wait for a human maintainer. Let's tackle that validation error together! 🚀

To resolve the validation error related to the missing fields tool_parameters.app.value and tool_parameters.app.type in the ToolNodeData, you need to ensure that the tool_parameters dictionary includes an entry for app with both value and type fields correctly defined. Here's how you can structure the tool_parameters:

tool_parameters = {
    "app": {
        "value": "your_app_value",  # This should be a string, list of strings, or a primitive type depending on the type
        "type": "mixed"  # or "variable" or "constant" depending on the nature of the value
    }
}

Make sure that:

  • If type is "mixed", value must be a string.
  • If type is "variable", value must be a list of strings.
  • If type is "constant", value must be a string, int, float, or bool.

Adjust the value and type according to the requirements of your specific tool and application logic [1].

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

@dosubot[bot] commented on GitHub (Apr 25, 2025): <!-- Greeting --> Hello @AAlexDing! I'm [Dosu](https://dosu.dev), your friendly bot here to help with bugs, answer questions, and guide you toward becoming a contributor! I'm ready to assist you while we wait for a human maintainer. Let's tackle that validation error together! 🚀 <!-- Answer --> To resolve the validation error related to the missing fields `tool_parameters.app.value` and `tool_parameters.app.type` in the `ToolNodeData`, you need to ensure that the `tool_parameters` dictionary includes an entry for `app` with both `value` and `type` fields correctly defined. Here's how you can structure the `tool_parameters`: ```python tool_parameters = { "app": { "value": "your_app_value", # This should be a string, list of strings, or a primitive type depending on the type "type": "mixed" # or "variable" or "constant" depending on the nature of the value } } ``` Make sure that: - If `type` is `"mixed"`, `value` must be a string. - If `type` is `"variable"`, `value` must be a list of strings. - If `type` is `"constant"`, `value` must be a string, int, float, or bool. Adjust the `value` and `type` according to the requirements of your specific tool and application logic <sup>[[1]](https://github.com/langgenius/dify/blob/main/api/core/workflow/nodes/tool/entities.py)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.* --- <sup>Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/a84faed0-8dfe-4d45-a5be-961756aaed3f?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/a84faed0-8dfe-4d45-a5be-961756aaed3f?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/a84faed0-8dfe-4d45-a5be-961756aaed3f?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/a84faed0-8dfe-4d45-a5be-961756aaed3f?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/a84faed0-8dfe-4d45-a5be-961756aaed3f?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/a84faed0-8dfe-4d45-a5be-961756aaed3f?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/a84faed0-8dfe-4d45-a5be-961756aaed3f?feedback_type=other)</sup>
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#13369