When the workflow output panel (log details) is a text output type, the front-end page will not render correctly when the result outputs is an array object consisting of strings. #7695

Closed
opened 2026-02-21 18:21:55 -05:00 by yindo · 4 comments
Owner

Originally created by @weiwenyan-dev on GitHub (Jan 13, 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

0.14.2

Cloud or Self Hosted

Self Hosted (Source)

Steps to reproduce

  1. Build a patent OA reply agent on Dify;
  2. Upload a PDF file;
  3. The operation shows success;
  4. Click the log to view the result, but it cannot be rendered;
  5. The result is an object, and the value is an array, which is made up of strings.

✔️ Expected Behavior

According to text type, display data and format normally.

Actual Behavior

The result page cannot be rendered.

Originally created by @weiwenyan-dev on GitHub (Jan 13, 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 0.14.2 ### Cloud or Self Hosted Self Hosted (Source) ### Steps to reproduce 1. Build a patent OA reply agent on Dify; 2. Upload a PDF file; 3. The operation shows success; 4. Click the log to view the result, but it cannot be rendered; 5. The result is an object, and the value is an array, which is made up of strings. ### ✔️ Expected Behavior According to text type, display data and format normally. ### ❌ Actual Behavior The result page cannot be rendered.
yindo closed this issue 2026-02-21 18:21:55 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Jan 13, 2025):

Hello @weiwenyan-dev! I'm here to assist you with any bugs, questions, or contributions you have for Dify. Let me know how I can help!

The issue you're experiencing with the front-end page not rendering correctly when the workflow output panel is a text output type and the result is an array of strings is due to the isTextOutput condition only checking for a single string. This condition does not account for arrays of strings, which prevents the rendering logic for text output from being triggered.

To fix this, you need to modify the isTextOutput condition to handle arrays of strings. You can update the condition to check if the output is an array and if all elements are strings, then join them into a single string for rendering. Here's how you can adjust the code:

const isTextOutput = useMemo(() => {
  if (!outputs || Object.keys(outputs).length !== 1) return false;
  const outputValue = outputs[Object.keys(outputs)[0]];
  return typeof outputValue === 'string' || 
         (Array.isArray(outputValue) && outputValue.every(item => typeof item === 'string'));
}, [outputs]);

And modify the rendering logic to handle arrays:

{isTextOutput && (
  <div className='px-4 py-2'>
    <Markdown content={Array.isArray(outputs[Object.keys(outputs)[0]]) 
      ? outputs[Object.keys(outputs)[0]].join('\n') 
      : outputs[Object.keys(outputs)[0]] || ''} />
  </div>
)}

This change ensures that arrays of strings are treated as text output and rendered correctly [1].

To continue talking to Dosu, mention @dosu.


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

@dosubot[bot] commented on GitHub (Jan 13, 2025): <!-- Greeting --> Hello @weiwenyan-dev! I'm here to assist you with any bugs, questions, or contributions you have for Dify. Let me know how I can help! <!-- Answer --> The issue you're experiencing with the front-end page not rendering correctly when the workflow output panel is a text output type and the result is an array of strings is due to the `isTextOutput` condition only checking for a single string. This condition does not account for arrays of strings, which prevents the rendering logic for text output from being triggered. To fix this, you need to modify the `isTextOutput` condition to handle arrays of strings. You can update the condition to check if the output is an array and if all elements are strings, then join them into a single string for rendering. Here's how you can adjust the code: ```tsx const isTextOutput = useMemo(() => { if (!outputs || Object.keys(outputs).length !== 1) return false; const outputValue = outputs[Object.keys(outputs)[0]]; return typeof outputValue === 'string' || (Array.isArray(outputValue) && outputValue.every(item => typeof item === 'string')); }, [outputs]); ``` And modify the rendering logic to handle arrays: ```tsx {isTextOutput && ( <div className='px-4 py-2'> <Markdown content={Array.isArray(outputs[Object.keys(outputs)[0]]) ? outputs[Object.keys(outputs)[0]].join('\n') : outputs[Object.keys(outputs)[0]] || ''} /> </div> )} ``` This change ensures that arrays of strings are treated as text output and rendered correctly <sup>[[1]](https://github.com/langgenius/dify/blob/main/web/app/components/workflow/run/output-panel.tsx)</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/61ba59db-fdac-40e4-a15e-e5e51dbb4e96?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/61ba59db-fdac-40e4-a15e-e5e51dbb4e96?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/61ba59db-fdac-40e4-a15e-e5e51dbb4e96?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/61ba59db-fdac-40e4-a15e-e5e51dbb4e96?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/61ba59db-fdac-40e4-a15e-e5e51dbb4e96?feedback_type=hallucination) | [Other](https://app.dosu.dev/response-feedback/61ba59db-fdac-40e4-a15e-e5e51dbb4e96?feedback_type=other)</sup>
Author
Owner

@crazywoola commented on GitHub (Jan 13, 2025):

LLM supports text or file only, if you want to render arrays please use template node to transform it.

@crazywoola commented on GitHub (Jan 13, 2025): LLM supports text or file only, if you want to render arrays please use template node to transform it.
Author
Owner

@weiwenyan-dev commented on GitHub (Jan 13, 2025):

LLM supports text or file only, if you want to render arrays please use template node to transform it.

What do you mean I found out about it myself and figured out how to fix it by submitting an issue first and then submitting the merge request

@weiwenyan-dev commented on GitHub (Jan 13, 2025): > LLM supports text or file only, if you want to render arrays please use template node to transform it. What do you mean I found out about it myself and figured out how to fix it by submitting an issue first and then submitting the merge request
Author
Owner

@crazywoola commented on GitHub (Jan 13, 2025):

LLM supports text or file only, if you want to render arrays please use template node to transform it.

What do you mean I found out about it myself and figured out how to fix it by submitting an issue first and then submitting the merge request

@crazywoola commented on GitHub (Jan 13, 2025): > > LLM supports text or file only, if you want to render arrays please use template node to transform it. > > What do you mean I found out about it myself and figured out how to fix it by submitting an issue first and then submitting the merge request
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#7695