using tool(custom work flow) error: output variable result[0] must be a string #10132

Closed
opened 2026-02-21 18:43:09 -05:00 by yindo · 0 comments
Owner

Originally created by @rainvstar on GitHub (Mar 10, 2025).

Hello, @rainvstar! I'm here to help you with your bug report and answer any questions you may have. Let's work together to resolve the issue you're facing.

To resolve the issue where the output variable result[0] must be a string, you need to transform the Array[Object] output into a text format. This is necessary because the Dify workflow output panel only supports text or file outputs directly.

You can achieve this transformation by using a template node or a code node. Here's an example of how you can use a code node to convert the array into a string:

def main(result: list):
# Assuming result is a list of objects, convert each object to a string representation
return {
"result": "\n".join([str(item) for item in result])
}
This script takes each object in the array, converts it to a string, and joins them with newline characters. Alternatively, you can use a template node to achieve a similar transformation [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

I return as string, but it still not work。

Image
Image
Image

Originally posted by @rainvstar in #15227

Image

Image

I try many times, I use python or http to request my service, the result type is string. I publish this workflow as tool . Then I use this tool in another workflow. It goes wrong ,and I can't find error logs in the docker logs.

Originally created by @rainvstar on GitHub (Mar 10, 2025). > Hello, [@rainvstar](https://github.com/rainvstar)! I'm here to help you with your bug report and answer any questions you may have. Let's work together to resolve the issue you're facing. > > To resolve the issue where the output variable `result[0]` must be a string, you need to transform the `Array[Object]` output into a text format. This is necessary because the Dify workflow output panel only supports text or file outputs directly. > > You can achieve this transformation by using a template node or a code node. Here's an example of how you can use a code node to convert the array into a string: > > def main(result: list): > # Assuming result is a list of objects, convert each object to a string representation > return { > "result": "\n".join([str(item) for item in result]) > } > This script takes each object in the array, converts it to a string, and joins them with newline characters. Alternatively, you can use a template node to achieve a similar transformation [[1]](https://github.com/langgenius/dify/issues/12682). > > _To continue talking to [Dosu](https://dosu.dev), mention [@dosu](https://github.com/dosu)._ > > Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/12710ebb-75f3-4983-a18b-fcf883a67720?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/12710ebb-75f3-4983-a18b-fcf883a67720?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/12710ebb-75f3-4983-a18b-fcf883a67720?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/12710ebb-75f3-4983-a18b-fcf883a67720?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/12710ebb-75f3-4983-a18b-fcf883a67720?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/12710ebb-75f3-4983-a18b-fcf883a67720?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/12710ebb-75f3-4983-a18b-fcf883a67720?feedback_type=other) > > > > I return as string, but it still not work。 > > ![Image](https://github.com/user-attachments/assets/9974b546-02a3-4170-97ca-8e7e14b7dcb6) > ![Image](https://github.com/user-attachments/assets/9ffdf08d-9528-4bbd-8b96-098630a78b25) > ![Image](https://github.com/user-attachments/assets/d8e5f23a-5aa0-42b2-b324-a1ba89ecd472) _Originally posted by @rainvstar in [#15227](https://github.com/langgenius/dify/issues/15227#issuecomment-2705944387)_ ![Image](https://github.com/user-attachments/assets/94cb3ef7-a353-45b5-ba37-385b3968e98f) ![Image](https://github.com/user-attachments/assets/46ab91e4-97a6-4707-9872-ef081b016a8a) I try many times, I use python or http to request my service, the result type is string. I publish this workflow as tool . Then I use this tool in another workflow. It goes wrong ,and I can't find error logs in the docker logs.
yindo added the 🐞 bug label 2026-02-21 18:43:09 -05:00
yindo closed this issue 2026-02-21 18:43:09 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#10132