invalid iterator value please provide a list #16716

Closed
opened 2026-02-21 19:27:18 -05:00 by yindo · 3 comments
Owner

Originally created by @huanyeruqiu on GitHub (Sep 3, 2025).

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • 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, otherwise it will be closed.
  • 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

1.8.1

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

An array object with structured output was generated using the GPT4O model, but an error occurred during iteration:
api-1            | [NodeRunStartedEvent]
api-1            | Node ID: 1756794183700
api-1            | Node Title: xxx
api-1            | Type: iteration
api-1            | 2025-09-04 01:57:46.471 ERROR [Thread-42 (_generate_worker)] [graph_engine.py:846] - Node xxx run failed
api-1            | Traceback (most recent call last):
api-1            |   File "/app/api/core/workflow/graph_engine/graph_engine.py", line 647, in _run_node
api-1            |     for event in event_stream:
api-1            |                  ^^^^^^^^^^^^
api-1            |   File "/app/api/core/workflow/nodes/base/node.py", line 78, in run
api-1            |     yield from result
api-1            |   File "/app/api/core/workflow/nodes/iteration/iteration_node.py", line 116, in _run
api-1            |     raise InvalidIteratorValueError(f"invalid iterator value: {variable}, please provide a list.")
api-1            | core.workflow.nodes.iteration.exc.InvalidIteratorValueError: invalid iterator value: value_type=<SegmentType.ARRAY_OBJECT: 'array[object]'> value=[{'section_title': ............

[GraphRunFailedEvent] reason: invalid iterator value: value_type=<SegmentType.ARRAY_OBJECT: 'array[object]'> value=[{'section_title': 'xxx', 'section_content': 'xxx'}, {'section_title': 'xxx', 'section_content': 'xxx'}], please provide a list.

✔️ Expected Behavior

Upgrading 1.7.2 before 1.8.1 is normal

Actual Behavior

No response

Originally created by @huanyeruqiu on GitHub (Sep 3, 2025). ### Self Checks - [x] I have read the [Contributing Guide](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) and [Language Policy](https://github.com/langgenius/dify/issues/1542). - [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, otherwise it will be closed. - [x] 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 1.8.1 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce ``` An array object with structured output was generated using the GPT4O model, but an error occurred during iteration: api-1 | [NodeRunStartedEvent] api-1 | Node ID: 1756794183700 api-1 | Node Title: xxx api-1 | Type: iteration api-1 | 2025-09-04 01:57:46.471 ERROR [Thread-42 (_generate_worker)] [graph_engine.py:846] - Node xxx run failed api-1 | Traceback (most recent call last): api-1 | File "/app/api/core/workflow/graph_engine/graph_engine.py", line 647, in _run_node api-1 | for event in event_stream: api-1 | ^^^^^^^^^^^^ api-1 | File "/app/api/core/workflow/nodes/base/node.py", line 78, in run api-1 | yield from result api-1 | File "/app/api/core/workflow/nodes/iteration/iteration_node.py", line 116, in _run api-1 | raise InvalidIteratorValueError(f"invalid iterator value: {variable}, please provide a list.") api-1 | core.workflow.nodes.iteration.exc.InvalidIteratorValueError: invalid iterator value: value_type=<SegmentType.ARRAY_OBJECT: 'array[object]'> value=[{'section_title': ............ [GraphRunFailedEvent] reason: invalid iterator value: value_type=<SegmentType.ARRAY_OBJECT: 'array[object]'> value=[{'section_title': 'xxx', 'section_content': 'xxx'}, {'section_title': 'xxx', 'section_content': 'xxx'}], please provide a list. ``` ### ✔️ Expected Behavior Upgrading 1.7.2 before 1.8.1 is normal ### ❌ Actual Behavior _No response_
yindo added the 🐞 bug label 2026-02-21 19:27:18 -05:00
yindo closed this issue 2026-02-21 19:27:18 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Sep 3, 2025):

Hi @huanyeruqiu! I'm Dosu and I’m helping the dify team.

This error happens because, in Dify 1.8.1, the iteration node strictly requires the input variable to be an instance of ArrayVariable (or a subclass like ArrayObjectVariable), not just a plain list or dict—even if the value looks like a list of objects. If the structured output from GPT-4o is being passed as a raw list of dicts (or not properly wrapped as an ArrayObjectVariable), the iteration node will reject it and throw this error. This is a stricter check than in 1.7.2, which is why your workflow worked before but fails now.

To fix this, make sure the variable passed to the iteration node is properly wrapped as an ArrayObjectVariable. You can do this by adding a "Code" node or a "list filter" node before the iteration node to ensure the input is a valid array[object] variable, not just a raw list. This approach has worked for similar issues with array[file] and structured outputs from LLMs in Dify workflows (example, example).

If you want to debug further, inspect the variable in the workflow output or add debug logging to confirm its type before it reaches the iteration node. If you continue to see this issue, upgrading to the latest Dify version may help, as recent releases have improved structured output handling and error reporting.

Let me know if you need a step-by-step example for the workaround!

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

@dosubot[bot] commented on GitHub (Sep 3, 2025): <!-- Greeting --> Hi @huanyeruqiu! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the dify team. <!-- Answer --> This error happens because, in Dify 1.8.1, the iteration node strictly requires the input variable to be an instance of ArrayVariable (or a subclass like ArrayObjectVariable), not just a plain list or dict—even if the value looks like a list of objects. If the structured output from GPT-4o is being passed as a raw list of dicts (or not properly wrapped as an ArrayObjectVariable), the iteration node will reject it and throw this error. This is a stricter check than in 1.7.2, which is why your workflow worked before but fails now. To fix this, make sure the variable passed to the iteration node is properly wrapped as an ArrayObjectVariable. You can do this by adding a "Code" node or a "list filter" node before the iteration node to ensure the input is a valid array[object] variable, not just a raw list. This approach has worked for similar issues with array[file] and structured outputs from LLMs in Dify workflows ([example](https://github.com/langgenius/dify/issues/12219), [example](https://github.com/langgenius/dify/issues/18836)). If you want to debug further, inspect the variable in the workflow output or add debug logging to confirm its type before it reaches the iteration node. If you continue to see this issue, upgrading to the latest Dify version may help, as recent releases have improved structured output handling and error reporting. Let me know if you need a step-by-step example for the workaround! <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/217e3c98-07ce-4f50-85b4-894fd6a05bf1?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/217e3c98-07ce-4f50-85b4-894fd6a05bf1?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/217e3c98-07ce-4f50-85b4-894fd6a05bf1?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/217e3c98-07ce-4f50-85b4-894fd6a05bf1?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/217e3c98-07ce-4f50-85b4-894fd6a05bf1?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/217e3c98-07ce-4f50-85b4-894fd6a05bf1?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/217e3c98-07ce-4f50-85b4-894fd6a05bf1?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/6088a4f4-073a-43f3-b3d4-4f06fb0c05a0/ask?utm_source=github)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify/issues/25120)
Author
Owner

@huanyeruqiu commented on GitHub (Sep 3, 2025):

def main(xxx) -> dict:
return {
"result": xxx,
}
Processing the data in Python before iteration can indeed solve this problem, but this approach seems meaningless and makes the workflow bloated

@huanyeruqiu commented on GitHub (Sep 3, 2025): def main(xxx) -> dict: return { "result": xxx, } Processing the data in Python before iteration can indeed solve this problem, but this approach seems meaningless and makes the workflow bloated
Author
Owner

@dosubot[bot] commented on GitHub (Oct 5, 2025):

Hi, @huanyeruqiu. I'm Dosu, and I'm helping the Dify team manage their backlog and am marking this issue as stale.

Issue Summary:

  • You encountered an InvalidIteratorValueError in Dify 1.8.1 due to iteration nodes expecting an ArrayVariable but receiving a raw list from GPT4O output.
  • The stricter type checking introduced in version 1.8.1 (compared to 1.7.2) requires wrapping raw lists as ArrayObjectVariable.
  • The recommended workaround is to use a "Code" or "list filter" node to wrap the list before iteration.
  • You noted that preprocessing data in Python works but adds complexity and bloats the workflow.
  • The issue was clarified and effectively resolved with this explanation and workaround.

What's Next:

  • Please let me know if this issue is still relevant with the latest version of Dify by commenting here.
  • Otherwise, I will automatically close this issue in 15 days.

Thank you for your understanding and contribution!

@dosubot[bot] commented on GitHub (Oct 5, 2025): Hi, @huanyeruqiu. I'm [Dosu](https://dosu.dev), and I'm helping the Dify team manage their backlog and am marking this issue as stale. **Issue Summary:** - You encountered an InvalidIteratorValueError in Dify 1.8.1 due to iteration nodes expecting an ArrayVariable but receiving a raw list from GPT4O output. - The stricter type checking introduced in version 1.8.1 (compared to 1.7.2) requires wrapping raw lists as ArrayObjectVariable. - The recommended workaround is to use a "Code" or "list filter" node to wrap the list before iteration. - You noted that preprocessing data in Python works but adds complexity and bloats the workflow. - The issue was clarified and effectively resolved with this explanation and workaround. **What's Next:** - Please let me know if this issue is still relevant with the latest version of Dify by commenting here. - Otherwise, I will automatically close this issue in 15 days. Thank you for your understanding and contribution!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#16716