The output of the direct reply node is abnormal in dify-0.8.2 but normal in dify-0.7.0 #5682

Closed
opened 2026-02-21 18:12:09 -05:00 by yindo · 1 comment
Owner

Originally created by @majestichou on GitHub (Sep 19, 2024).

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.8.2

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

  1. Download the source code of dify-0.8.2 from link
  2. Decompress the .zip file and go to the directory: dify-0.8.2/docker
  3. Run the docker composer up -d command
  4. Open Chrome and access localhost
  5. Create a Chat-Flow named test-direct-answer-node by importing DSL file of test-direct-answer-node.yml
    The content of test-direct-answer-node.yml is as follows:
app:
  description: ''
  icon: 🤖
  icon_background: '#FFEAD5'
  mode: advanced-chat
  name: test-direct-answer-node
  use_icon_as_answer_icon: false
kind: app
version: 0.1.2
workflow:
  conversation_variables: []
  environment_variables: []
  features:
    file_upload:
      image:
        enabled: false
        number_limits: 3
        transfer_methods:
        - local_file
        - remote_url
    opening_statement: ''
    retriever_resource:
      enabled: true
    sensitive_word_avoidance:
      enabled: false
    speech_to_text:
      enabled: false
    suggested_questions: []
    suggested_questions_after_answer:
      enabled: false
    text_to_speech:
      enabled: false
      language: ''
      voice: ''
  graph:
    edges:
    - data:
        isInIteration: false
        sourceType: start
        targetType: code
      id: 1726728238724-source-1726728272123-target
      source: '1726728238724'
      sourceHandle: source
      target: '1726728272123'
      targetHandle: target
      type: custom
      zIndex: 0
    - data:
        isInIteration: false
        sourceType: code
        targetType: iteration
      id: 1726728272123-source-1726728343932-target
      source: '1726728272123'
      sourceHandle: source
      target: '1726728343932'
      targetHandle: target
      type: custom
      zIndex: 0
    - data:
        isInIteration: true
        iteration_id: '1726728343932'
        sourceType: iteration-start
        targetType: code
      id: 1726728343932start-source-1726728354508-target
      source: 1726728343932start
      sourceHandle: source
      target: '1726728354508'
      targetHandle: target
      type: custom
      zIndex: 1002
    - data:
        isInIteration: true
        iteration_id: '1726728343932'
        sourceType: code
        targetType: answer
      id: 1726728354508-source-1726728375261-target
      source: '1726728354508'
      sourceHandle: source
      target: '1726728375261'
      targetHandle: target
      type: custom
      zIndex: 1002
    - data:
        isInIteration: false
        sourceType: iteration
        targetType: answer
      id: 1726728343932-source-answer-target
      source: '1726728343932'
      sourceHandle: source
      target: answer
      targetHandle: target
      type: custom
      zIndex: 0
    nodes:
    - data:
        desc: ''
        selected: false
        title: 开始
        type: start
        variables: []
      height: 54
      id: '1726728238724'
      position:
        x: 80
        y: 282
      positionAbsolute:
        x: 80
        y: 282
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 244
    - data:
        answer: '****************************

          Test!!!

          ****************************'
        desc: ''
        selected: false
        title: 直接回复
        type: answer
        variables: []
      height: 120
      id: answer
      position:
        x: 1455
        y: 282
      positionAbsolute:
        x: 1455
        y: 282
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 244
    - data:
        code: "\ndef main() -> dict:\n    return {\n        \"result\": ['1', '2',\
          \ '2'],\n    }\n"
        code_language: python3
        desc: ''
        outputs:
          result:
            children: null
            type: array[string]
        selected: false
        title: 代码执行
        type: code
        variables: []
      height: 54
      id: '1726728272123'
      position:
        x: 384
        y: 282
      positionAbsolute:
        x: 384
        y: 282
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 244
    - data:
        desc: ''
        height: 211
        iterator_selector:
        - '1726728272123'
        - result
        output_selector:
        - '1726728354508'
        - result
        output_type: array[string]
        selected: false
        start_node_id: 1726728343932start
        title: 迭代
        type: iteration
        width: 692
      height: 211
      id: '1726728343932'
      position:
        x: 688
        y: 282
      positionAbsolute:
        x: 688
        y: 282
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 692
      zIndex: 1
    - data:
        desc: ''
        isInIteration: true
        selected: false
        title: ''
        type: iteration-start
      draggable: false
      height: 44
      id: 1726728343932start
      parentId: '1726728343932'
      position:
        x: 24
        y: 68
      positionAbsolute:
        x: 712
        y: 350
      selectable: false
      sourcePosition: right
      targetPosition: left
      type: custom-iteration-start
      width: 44
      zIndex: 1002
    - data:
        code: "\ndef main() -> dict:\n    return {\n        \"result\": 'Line1',\n\
          \    }\n"
        code_language: python3
        desc: ''
        isInIteration: true
        iteration_id: '1726728343932'
        outputs:
          result:
            children: null
            type: string
        selected: false
        title: 代码执行 2
        type: code
        variables: []
      height: 54
      id: '1726728354508'
      parentId: '1726728343932'
      position:
        x: 128
        y: 68
      positionAbsolute:
        x: 816
        y: 350
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 244
      zIndex: 1002
    - data:
        answer: '*********************

          {{#1726728354508.result#}}

          *********************'
        desc: ''
        isInIteration: true
        iteration_id: '1726728343932'
        selected: false
        title: 直接回复 2
        type: answer
        variables: []
      height: 139
      id: '1726728375261'
      parentId: '1726728343932'
      position:
        x: 417.48541298149826
        y: 52
      positionAbsolute:
        x: 1105.4854129814983
        y: 334
      selected: true
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 244
      zIndex: 1002
    viewport:
      x: 10.624668937227852
      y: 113.7582585875706
      zoom: 0.757858283255199
  1. Run the app, the output is as follows:

Test!!!


Line1


Line1


Line1


  1. This print order is wrong!!!. The right output should be:

Line1


Line1


Line1


Test!!!


  1. I created the same app on dify's official website(https://cloud.dify.ai/) and printing is normal. And, I created the same app on dify-0.7.0 version(docker) and printing is normal.

✔️ Expected Behavior

The right output should be:


Line1


Line1


Line1


Test!!!


Actual Behavior

the output is as follows:


Test!!!


Line1


Line1


Line1


Originally created by @majestichou on GitHub (Sep 19, 2024). ### 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.8.2 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce 1. Download the source code of dify-0.8.2 from [link](https://github.com/langgenius/dify/releases/tag/0.8.2) 2. Decompress the .zip file and go to the directory: `dify-0.8.2/docker` 3. Run the `docker composer up -d` command 4. Open Chrome and access localhost 5. Create a Chat-Flow named `test-direct-answer-node` by importing DSL file of `test-direct-answer-node.yml` The content of `test-direct-answer-node.yml` is as follows: ``` app: description: '' icon: 🤖 icon_background: '#FFEAD5' mode: advanced-chat name: test-direct-answer-node use_icon_as_answer_icon: false kind: app version: 0.1.2 workflow: conversation_variables: [] environment_variables: [] features: file_upload: image: enabled: false number_limits: 3 transfer_methods: - local_file - remote_url opening_statement: '' retriever_resource: enabled: true sensitive_word_avoidance: enabled: false speech_to_text: enabled: false suggested_questions: [] suggested_questions_after_answer: enabled: false text_to_speech: enabled: false language: '' voice: '' graph: edges: - data: isInIteration: false sourceType: start targetType: code id: 1726728238724-source-1726728272123-target source: '1726728238724' sourceHandle: source target: '1726728272123' targetHandle: target type: custom zIndex: 0 - data: isInIteration: false sourceType: code targetType: iteration id: 1726728272123-source-1726728343932-target source: '1726728272123' sourceHandle: source target: '1726728343932' targetHandle: target type: custom zIndex: 0 - data: isInIteration: true iteration_id: '1726728343932' sourceType: iteration-start targetType: code id: 1726728343932start-source-1726728354508-target source: 1726728343932start sourceHandle: source target: '1726728354508' targetHandle: target type: custom zIndex: 1002 - data: isInIteration: true iteration_id: '1726728343932' sourceType: code targetType: answer id: 1726728354508-source-1726728375261-target source: '1726728354508' sourceHandle: source target: '1726728375261' targetHandle: target type: custom zIndex: 1002 - data: isInIteration: false sourceType: iteration targetType: answer id: 1726728343932-source-answer-target source: '1726728343932' sourceHandle: source target: answer targetHandle: target type: custom zIndex: 0 nodes: - data: desc: '' selected: false title: 开始 type: start variables: [] height: 54 id: '1726728238724' position: x: 80 y: 282 positionAbsolute: x: 80 y: 282 selected: false sourcePosition: right targetPosition: left type: custom width: 244 - data: answer: '**************************** Test!!! ****************************' desc: '' selected: false title: 直接回复 type: answer variables: [] height: 120 id: answer position: x: 1455 y: 282 positionAbsolute: x: 1455 y: 282 selected: false sourcePosition: right targetPosition: left type: custom width: 244 - data: code: "\ndef main() -> dict:\n return {\n \"result\": ['1', '2',\ \ '2'],\n }\n" code_language: python3 desc: '' outputs: result: children: null type: array[string] selected: false title: 代码执行 type: code variables: [] height: 54 id: '1726728272123' position: x: 384 y: 282 positionAbsolute: x: 384 y: 282 selected: false sourcePosition: right targetPosition: left type: custom width: 244 - data: desc: '' height: 211 iterator_selector: - '1726728272123' - result output_selector: - '1726728354508' - result output_type: array[string] selected: false start_node_id: 1726728343932start title: 迭代 type: iteration width: 692 height: 211 id: '1726728343932' position: x: 688 y: 282 positionAbsolute: x: 688 y: 282 selected: false sourcePosition: right targetPosition: left type: custom width: 692 zIndex: 1 - data: desc: '' isInIteration: true selected: false title: '' type: iteration-start draggable: false height: 44 id: 1726728343932start parentId: '1726728343932' position: x: 24 y: 68 positionAbsolute: x: 712 y: 350 selectable: false sourcePosition: right targetPosition: left type: custom-iteration-start width: 44 zIndex: 1002 - data: code: "\ndef main() -> dict:\n return {\n \"result\": 'Line1',\n\ \ }\n" code_language: python3 desc: '' isInIteration: true iteration_id: '1726728343932' outputs: result: children: null type: string selected: false title: 代码执行 2 type: code variables: [] height: 54 id: '1726728354508' parentId: '1726728343932' position: x: 128 y: 68 positionAbsolute: x: 816 y: 350 selected: false sourcePosition: right targetPosition: left type: custom width: 244 zIndex: 1002 - data: answer: '********************* {{#1726728354508.result#}} *********************' desc: '' isInIteration: true iteration_id: '1726728343932' selected: false title: 直接回复 2 type: answer variables: [] height: 139 id: '1726728375261' parentId: '1726728343932' position: x: 417.48541298149826 y: 52 positionAbsolute: x: 1105.4854129814983 y: 334 selected: true sourcePosition: right targetPosition: left type: custom width: 244 zIndex: 1002 viewport: x: 10.624668937227852 y: 113.7582585875706 zoom: 0.757858283255199 ``` 6. Run the app, the output is as follows: **************************** Test!!! ************************************************* Line1 ****************************************** Line1 ****************************************** Line1 ********************* 7. **This print order is wrong!!!**. The right output should be: **************************** Line1 ******************************************************** Line1 ******************************************************** Line1 **************************************************** Test!!! ************************ 8. **I created the same app on dify's official website(https://cloud.dify.ai/) and printing is normal. And, I created the same app on dify-0.7.0 version(docker) and printing is normal.** ### ✔️ Expected Behavior The right output should be: **************************** Line1 ******************************************************** Line1 ******************************************************** Line1 **************************************************** Test!!! ************************ ### ❌ Actual Behavior the output is as follows: **************************** Test!!! ************************************************* Line1 ****************************************** Line1 ****************************************** Line1 *********************
yindo added the 🐞 bug label 2026-02-21 18:12:09 -05:00
yindo closed this issue 2026-02-21 18:12:09 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Sep 19, 2024):

The output of the direct reply node is abnormal in dify-0.8.2 because the output variable of the iteration node is in array format and cannot be directly output. In dify-0.8.2, you need to convert the array back to text before using the direct reply node. This step might not have been necessary or was handled differently in dify-0.7.0.

To fix this, you can use a code node or a template node to convert the array to text before the direct reply node. Here is an example using a code node:

def main(articleSections: list):
    data = articleSections
    return {
        "result": "\n".join(data)
    }

Or using a template node:

{{ articleSections | join("\n") }}

This conversion ensures that the direct reply node receives the data in the correct format for output [1].

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Sep 19, 2024): <!-- Answer --> The output of the direct reply node is abnormal in dify-0.8.2 because the output variable of the iteration node is in array format and cannot be directly output. In dify-0.8.2, you need to convert the array back to text before using the direct reply node. This step might not have been necessary or was handled differently in dify-0.7.0. To fix this, you can use a code node or a template node to convert the array to text before the direct reply node. Here is an example using a code node: ```python def main(articleSections: list): data = articleSections return { "result": "\n".join(data) } ``` Or using a template node: ```django {{ articleSections | join("\n") }} ``` This conversion ensures that the direct reply node receives the data in the correct format for output <sup>[[1]](https://github.com/langgenius/dify-docs/blob/main/en/guides/workflow/node/iteration.md)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#5682