[PR #30082] fix: allow None values in VariableMessage validation #32673

Closed
opened 2026-02-21 20:51:51 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langgenius/dify/pull/30082

State: closed
Merged: Yes


Summary

Fix workflow-as-tool invocation failing when output variables contain null values.

Problem

When calling a workflow as a tool, if any output variable has a null value, the tool invocation fails with:

1 validation error for VariableMessage
Value error, Only basic types and lists are allowed.

Root Cause

In api/core/tools/entities/tool_entities.py, the VariableMessage.transform_variable_value validator only allows dict | list | str | int | float | bool types, but does not allow None.

When a workflow End node outputs contain null values (e.g., {"result": "data", "optional_field": null}), the WorkflowTool._invoke() method passes these None values to create_variable_message(), which fails the validation.

Solution

Update the validation to allow None values by checking if value is not None before the isinstance check.

Related to #30069

Test Plan

  • Create a workflow with multiple output variables where some may be null
  • Call the workflow as a tool from another workflow or agent
  • Verify that null output values no longer cause validation errors
**Original Pull Request:** https://github.com/langgenius/dify/pull/30082 **State:** closed **Merged:** Yes --- ## Summary Fix workflow-as-tool invocation failing when output variables contain `null` values. ### Problem When calling a workflow as a tool, if any output variable has a `null` value, the tool invocation fails with: ``` 1 validation error for VariableMessage Value error, Only basic types and lists are allowed. ``` ### Root Cause In `api/core/tools/entities/tool_entities.py`, the `VariableMessage.transform_variable_value` validator only allows `dict | list | str | int | float | bool` types, but does not allow `None`. When a workflow End node outputs contain `null` values (e.g., `{"result": "data", "optional_field": null}`), the `WorkflowTool._invoke()` method passes these `None` values to `create_variable_message()`, which fails the validation. ### Solution Update the validation to allow `None` values by checking `if value is not None` before the isinstance check. Related to #30069 ## Test Plan - [ ] Create a workflow with multiple output variables where some may be null - [ ] Call the workflow as a tool from another workflow or agent - [ ] Verify that null output values no longer cause validation errors
yindo added the pull-request label 2026-02-21 20:51:51 -05:00
yindo closed this issue 2026-02-21 20:51:51 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#32673