langgenius / dify

Dify is an open-source LLM app development platform. Dify's intuitive interface combines AI workflow, RAG pipeline, agent capabilities, model management, observability features and more, letting you quickly go from prototype to production.
https://dify.ai
Other
46.4k stars 6.55k forks source link

0.8.0 also raise error validation error for VariableAssignerNodeData #8738

Open yuhp-zts opened 2 hours ago

yuhp-zts commented 2 hours ago

Self Checks

Dify version

0.8.0

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

Iteration node in chatflow:an error occurs. { "iterator_selector": [ { "company": "company 1", "tools": { "tool1": "tool 1", "tool2": "tool 2" } }, { "company": "company 2", "tools": { "tool2": "tool2" } } ] }

image

image

2024-09-25 01:42:10,831.831 ERROR [Thread-96 (_generate_worker)] [graph_engine.py:184] - Unknown Error when graph running Traceback (most recent call last): File "/app/api/core/workflow/graph_engine/graph_engine.py", line 145, in run for item in generator: File "/app/api/core/workflow/nodes/answer/answer_stream_processor.py", line 30, in process for event in generator: File "/app/api/core/workflow/graph_engine/graph_engine.py", line 233, in _run node_instance = node_cls( # type: ignore File "/app/api/core/workflow/nodes/base_node.py", line 48, in init self.node_data = self._node_data_cls(**config.get("data", {})) File "/app/api/.venv/lib/python3.10/site-packages/pydantic/main.py", line 193, in init self.__pydantic_validator__.validate_python(data, self_instance=self) pydantic_core._pydantic_core.ValidationError: 1 validation error for VariableAssignerNodeData advanced_settings.groups.0.output_type Input should be 'string', 'number', 'object', 'array[string]', 'array[number]' or 'array[object]' [type=literal_error, input_value='any', input_type=str] For further information visit https://errors.pydantic.dev/2.8/v/literal_error

✔️ Expected Behavior

No response

❌ Actual Behavior

No response

dosubot[bot] commented 2 hours ago

I found a similar unsolved discussion regarding an "Invalid variable" error in the Dify repository [1].

The validation error for VariableAssignerNodeData in version 0.8.0 occurs because the VariableAssignerNode class expects the node_data to be of type VariableAssignerData. If the node_data does not conform to this expected type, it will raise a validation error. The structure and type definition of VariableAssignerData are as follows:

class VariableAssignerData(BaseNodeData):
    title: str = "Variable Assigner"
    desc: Optional[str] = "Assign a value to a variable"
    assigned_variable_selector: Sequence[str]
    write_mode: WriteMode
    input_variable_selector: Sequence[str]

In the _run method of VariableAssignerNode, self.node_data is cast to VariableAssignerData. If self.node_data does not match the structure and type of VariableAssignerData, it will result in a validation error [2].

Additionally, ensure that the iterator_selector and output_selector in the IterationNode are correctly configured and validated. The iterator_selector should point to a valid list in the VariablePool, and the data being iterated over should match the expected types [3][4].

To avoid such issues, make sure that the conversation variables are correctly defined and used within the chatflow. Conversation variables allow application developers to specify particular information that needs to be temporarily stored within the same Chatflow session, ensuring that this information can be referenced across multiple rounds of chatting within the current chatflow [5].

If you need further assistance, please provide more details about the specific configuration and data being used in your chatflow.

To continue talking to Dosu, mention @dosu.

yuhp-zts commented 1 hour ago

When I export the workflow and reload it, the error is gone.