iteration node runs #20565

Closed
opened 2026-02-21 20:07:58 -05:00 by yindo · 5 comments
Owner

Originally created by @userGuo-o on GitHub (Nov 26, 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

2.0.0-beta2

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

Every time the iteration node runs, it keeps running and can cause system lag and model loading issues

✔️ Expected Behavior

2025-11-26 16:16:13.145 WARNING [Dummy-229] [provider_configuration.py:1702] - get custom model schema failed, req_id: ea9aee2633 PluginInvokeError: {"error_type":"unmarshal_error","message":"unmarshal json failed: use_template enable_thinking not found"}
[2025-11-26 08:16:59 +0000] [114] [ERROR] Error handling request
Traceback (most recent call last):
File "/app/api/.venv/lib/python3.12/site-packages/gunicorn/workers/base_async.py", line 114, in handle_request
for item in respiter:
^^^^^^^^
File "/app/api/.venv/lib/python3.12/site-packages/werkzeug/wsgi.py", line 256, in next
return self._next()
^^^^^^^^^^^^
File "/app/api/.venv/lib/python3.12/site-packages/werkzeug/wrappers/response.py", line 32, in _iter_encoded
for item in iterable:
^^^^^^^^
File "/app/api/.venv/lib/python3.12/site-packages/flask/helpers.py", line 132, in generator
yield from gen
File "/app/api/libs/helper.py", line 214, in generate
yield from response
File "/app/api/core/app/features/rate_limiting/rate_limit.py", line 120, in next
return next(self.generator)
^^^^^^^^^^^^^^^^^^^^
File "/app/api/core/app/apps/base_app_generator.py", line 176, in gen
for message in generator:
^^^^^^^^^
File "/app/api/core/app/apps/base_app_generate_response_converter.py", line 27, in _generate_full_response
yield from cls.convert_stream_full_response(response)
File "/app/api/core/app/apps/workflow/generate_response_converter.py", line 46, in convert_stream_full_response
for chunk in stream_response:
^^^^^^^^^^^^^^^
File "/app/api/core/app/apps/workflow/generate_task_pipeline.py", line 190, in _to_stream_response
for stream_response in generator:
^^^^^^^^^
File "/app/api/core/app/apps/workflow/generate_task_pipeline.py", line 221, in _wrapper_process_stream_response
for response in self._process_stream_response(tts_publisher=tts_publisher, trace_manager=trace_manager):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/core/app/apps/workflow/generate_task_pipeline.py", line 686, in _process_stream_response
if responses := list(
^^^^^
File "/app/api/core/app/apps/workflow/generate_task_pipeline.py", line 615, in _dispatch_event
yield from handler(
File "/app/api/core/app/apps/workflow/generate_task_pipeline.py", line 373, in _handle_iteration_start_event
iter_start_resp = self._workflow_response_converter.workflow_iteration_start_to_stream_response(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/core/app/apps/common/workflow_response_converter.py", line 288, in workflow_iteration_start_to_stream_response
new_inputs, truncated = self._truncator.truncate_variable_mapping(event.inputs or {})
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/services/variable_truncator.py", line 150, in truncate_variable_mapping
part_result = self._truncate_json_primitives(value, value_budget)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/services/variable_truncator.py", line 413, in _truncate_json_primitives
return self._truncate_array(val, target_size)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/services/variable_truncator.py", line 298, in _truncate_array
part_result = self._truncate_json_primitives(item, target_size - used_size)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/services/variable_truncator.py", line 419, in _truncate_json_primitives
raise AssertionError("this statement should be unreachable.")
AssertionError: this statement should be unreachable.

[2025-11-26 08:18:29 +0000] [100] [ERROR] Error handling request Traceback (most recent call last): File "/app/api/.venv/lib/python3.12/site-packages/gunicorn/workers/base_async.py", line 114, in handle_request for item in respiter: ^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/werkzeug/wsgi.py", line 256, in next return self._next() ^^^^^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/werkzeug/wrappers/response.py", line 32, in _iter_encoded for item in iterable: ^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/flask/helpers.py", line 132, in generator yield from gen File "/app/api/libs/helper.py", line 214, in generate yield from response File "/app/api/core/app/features/rate_limiting/rate_limit.py", line 120, in next return next(self.generator) ^^^^^^^^^^^^^^^^^^^^ File "/app/api/core/app/apps/base_app_generator.py", line 176, in gen for message in generator: ^^^^^^^^^ File "/app/api/core/app/apps/base_app_generate_response_converter.py", line 27, in _generate_full_response yield from cls.convert_stream_full_response(response) File "/app/api/core/app/apps/workflow/generate_response_converter.py", line 46, in convert_stream_full_response for chunk in stream_response: ^^^^^^^^^^^^^^^ File "/app/api/core/app/apps/workflow/generate_task_pipeline.py", line 190, in _to_stream_response for stream_response in generator: ^^^^^^^^^ File "/app/api/core/app/apps/workflow/generate_task_pipeline.py", line 221, in _wrapper_process_stream_response for response in self._process_stream_response(tts_publisher=tts_publisher, trace_manager=trace_manager): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/core/app/apps/workflow/generate_task_pipeline.py", line 686, in _process_stream_response if responses := list( ^^^^^ File "/app/api/core/app/apps/workflow/generate_task_pipeline.py", line 615, in _dispatch_event yield from handler( File "/app/api/core/app/apps/workflow/generate_task_pipeline.py", line 373, in _handle_iteration_start_event iter_start_resp = self._workflow_response_converter.workflow_iteration_start_to_stream_response( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/core/app/apps/common/workflow_response_converter.py", line 288, in workflow_iteration_start_to_stream_response new_inputs, truncated = self._truncator.truncate_variable_mapping(event.inputs or {}) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/services/variable_truncator.py", line 150, in truncate_variable_mapping part_result = self._truncate_json_primitives(value, value_budget) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/services/variable_truncator.py", line 413, in _truncate_json_primitives return self._truncate_array(val, target_size) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/services/variable_truncator.py", line 298, in _truncate_array part_result = self._truncate_json_primitives(item, target_size - used_size) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/services/variable_truncator.py", line 419, in _truncate_json_primitives raise AssertionError("this statement should be unreachable.") AssertionError: this statement should be unreachable. 2025-11-26 16:18:29.977 WARNING [GraphDispatcher] [event_handlers.py:128] - Unhandled event type: NodeRunRetrieverResourceEvent 2025-11-26 16:18:31.876 ERROR [GraphWorker-0] [base.py:211] - Error in stream reponse for plugin {'code': -500, 'message': '{"message":"{\"args\":{},\"error_type\":\"ValueError\",\"message\":\"{'object': 'error', 'message': '[00:18:31] /workspace/cpp/json_schema_converter.cc:552: Check failed: (schema.is\\u003cpicojson::object\\u003e()) is false: Schema should be an object or bool\\\\n', 'type': 'BadRequestError', 'param': None, 'code': 400}\"}","error_type":"PluginInvokeError","args":null}', 'data': None} 2025-11-26 16:18:31.877 ERROR [GraphDispatcher] [abort_strategy.py:37] - Node 1764058346871 failed with ABORT strategy: [vllm] Error: req_id: 166a417c6a PluginInvokeError: {"args":{},"error_type":"ValueError","message":"{'object': 'error', 'message': '[00:18:31] /workspace/cpp/json_schema_converter.cc:552: Check failed: (schema.is\u003cpicojson::object\u003e()) is false: Schema should be an object or bool\n', 'type': 'BadRequestError', 'param': None, 'code': 400}"} 2025-11-26 16:18:32.085 ERROR [Thread-2403 (_generate_worker)] [workflow_entry.py:119] - Unknown Error when workflow entry running Traceback (most recent call last): File "/app/api/core/workflow/workflow_entry.py", line 115, in run yield from generator File "/app/api/core/workflow/graph_engine/graph_engine.py", line 276, in run raise self._graph_execution.error RuntimeError: [vllm] Error: req_id: 166a417c6a PluginInvokeError: {"args":{},"error_type":"ValueError","message":"{'object': 'error', 'message': '[00:18:31] /workspace/cpp/json_schema_converter.cc:552: Check failed: (schema.is\u003cpicojson::object\u003e()) is false: Schema should be an object or bool\n', 'type': 'BadRequestError', 'param': None, 'code': 400}"}

Actual Behavior

No response

Originally created by @userGuo-o on GitHub (Nov 26, 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 2.0.0-beta2 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce Every time the iteration node runs, it keeps running and can cause system lag and model loading issues ### ✔️ Expected Behavior 2025-11-26 16:16:13.145 WARNING [Dummy-229] [provider_configuration.py:1702] - get custom model schema failed, req_id: ea9aee2633 PluginInvokeError: {"error_type":"unmarshal_error","message":"unmarshal json failed: use_template enable_thinking not found"} [2025-11-26 08:16:59 +0000] [114] [ERROR] Error handling request Traceback (most recent call last): File "/app/api/.venv/lib/python3.12/site-packages/gunicorn/workers/base_async.py", line 114, in handle_request for item in respiter: ^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/werkzeug/wsgi.py", line 256, in __next__ return self._next() ^^^^^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/werkzeug/wrappers/response.py", line 32, in _iter_encoded for item in iterable: ^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/flask/helpers.py", line 132, in generator yield from gen File "/app/api/libs/helper.py", line 214, in generate yield from response File "/app/api/core/app/features/rate_limiting/rate_limit.py", line 120, in __next__ return next(self.generator) ^^^^^^^^^^^^^^^^^^^^ File "/app/api/core/app/apps/base_app_generator.py", line 176, in gen for message in generator: ^^^^^^^^^ File "/app/api/core/app/apps/base_app_generate_response_converter.py", line 27, in _generate_full_response yield from cls.convert_stream_full_response(response) File "/app/api/core/app/apps/workflow/generate_response_converter.py", line 46, in convert_stream_full_response for chunk in stream_response: ^^^^^^^^^^^^^^^ File "/app/api/core/app/apps/workflow/generate_task_pipeline.py", line 190, in _to_stream_response for stream_response in generator: ^^^^^^^^^ File "/app/api/core/app/apps/workflow/generate_task_pipeline.py", line 221, in _wrapper_process_stream_response for response in self._process_stream_response(tts_publisher=tts_publisher, trace_manager=trace_manager): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/core/app/apps/workflow/generate_task_pipeline.py", line 686, in _process_stream_response if responses := list( ^^^^^ File "/app/api/core/app/apps/workflow/generate_task_pipeline.py", line 615, in _dispatch_event yield from handler( File "/app/api/core/app/apps/workflow/generate_task_pipeline.py", line 373, in _handle_iteration_start_event iter_start_resp = self._workflow_response_converter.workflow_iteration_start_to_stream_response( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/core/app/apps/common/workflow_response_converter.py", line 288, in workflow_iteration_start_to_stream_response new_inputs, truncated = self._truncator.truncate_variable_mapping(event.inputs or {}) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/services/variable_truncator.py", line 150, in truncate_variable_mapping part_result = self._truncate_json_primitives(value, value_budget) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/services/variable_truncator.py", line 413, in _truncate_json_primitives return self._truncate_array(val, target_size) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/services/variable_truncator.py", line 298, in _truncate_array part_result = self._truncate_json_primitives(item, target_size - used_size) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/services/variable_truncator.py", line 419, in _truncate_json_primitives raise AssertionError("this statement should be unreachable.") AssertionError: this statement should be unreachable. [2025-11-26 08:18:29 +0000] [100] [ERROR] Error handling request Traceback (most recent call last): File "/app/api/.venv/lib/python3.12/site-packages/gunicorn/workers/base_async.py", line 114, in handle_request for item in respiter: ^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/werkzeug/wsgi.py", line 256, in __next__ return self._next() ^^^^^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/werkzeug/wrappers/response.py", line 32, in _iter_encoded for item in iterable: ^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/flask/helpers.py", line 132, in generator yield from gen File "/app/api/libs/helper.py", line 214, in generate yield from response File "/app/api/core/app/features/rate_limiting/rate_limit.py", line 120, in __next__ return next(self.generator) ^^^^^^^^^^^^^^^^^^^^ File "/app/api/core/app/apps/base_app_generator.py", line 176, in gen for message in generator: ^^^^^^^^^ File "/app/api/core/app/apps/base_app_generate_response_converter.py", line 27, in _generate_full_response yield from cls.convert_stream_full_response(response) File "/app/api/core/app/apps/workflow/generate_response_converter.py", line 46, in convert_stream_full_response for chunk in stream_response: ^^^^^^^^^^^^^^^ File "/app/api/core/app/apps/workflow/generate_task_pipeline.py", line 190, in _to_stream_response for stream_response in generator: ^^^^^^^^^ File "/app/api/core/app/apps/workflow/generate_task_pipeline.py", line 221, in _wrapper_process_stream_response for response in self._process_stream_response(tts_publisher=tts_publisher, trace_manager=trace_manager): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/core/app/apps/workflow/generate_task_pipeline.py", line 686, in _process_stream_response if responses := list( ^^^^^ File "/app/api/core/app/apps/workflow/generate_task_pipeline.py", line 615, in _dispatch_event yield from handler( File "/app/api/core/app/apps/workflow/generate_task_pipeline.py", line 373, in _handle_iteration_start_event iter_start_resp = self._workflow_response_converter.workflow_iteration_start_to_stream_response( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/core/app/apps/common/workflow_response_converter.py", line 288, in workflow_iteration_start_to_stream_response new_inputs, truncated = self._truncator.truncate_variable_mapping(event.inputs or {}) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/services/variable_truncator.py", line 150, in truncate_variable_mapping part_result = self._truncate_json_primitives(value, value_budget) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/services/variable_truncator.py", line 413, in _truncate_json_primitives return self._truncate_array(val, target_size) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/services/variable_truncator.py", line 298, in _truncate_array part_result = self._truncate_json_primitives(item, target_size - used_size) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/services/variable_truncator.py", line 419, in _truncate_json_primitives raise AssertionError("this statement should be unreachable.") AssertionError: this statement should be unreachable. 2025-11-26 16:18:29.977 WARNING [GraphDispatcher] [event_handlers.py:128] - Unhandled event type: NodeRunRetrieverResourceEvent 2025-11-26 16:18:31.876 ERROR [GraphWorker-0] [base.py:211] - Error in stream reponse for plugin {'code': -500, 'message': '{"message":"{\\"args\\":{},\\"error_type\\":\\"ValueError\\",\\"message\\":\\"{\'object\': \'error\', \'message\': \'[00:18:31] /workspace/cpp/json_schema_converter.cc:552: Check failed: (schema.is\\\\u003cpicojson::object\\\\u003e()) is false: Schema should be an object or bool\\\\\\\\n\', \'type\': \'BadRequestError\', \'param\': None, \'code\': 400}\\"}","error_type":"PluginInvokeError","args":null}', 'data': None} 2025-11-26 16:18:31.877 ERROR [GraphDispatcher] [abort_strategy.py:37] - Node 1764058346871 failed with ABORT strategy: [vllm] Error: req_id: 166a417c6a PluginInvokeError: {"args":{},"error_type":"ValueError","message":"{'object': 'error', 'message': '[00:18:31] /workspace/cpp/json_schema_converter.cc:552: Check failed: (schema.is\u003cpicojson::object\u003e()) is false: Schema should be an object or bool\\n', 'type': 'BadRequestError', 'param': None, 'code': 400}"} 2025-11-26 16:18:32.085 ERROR [Thread-2403 (_generate_worker)] [workflow_entry.py:119] - Unknown Error when workflow entry running Traceback (most recent call last): File "/app/api/core/workflow/workflow_entry.py", line 115, in run yield from generator File "/app/api/core/workflow/graph_engine/graph_engine.py", line 276, in run raise self._graph_execution.error RuntimeError: [vllm] Error: req_id: 166a417c6a PluginInvokeError: {"args":{},"error_type":"ValueError","message":"{'object': 'error', 'message': '[00:18:31] /workspace/cpp/json_schema_converter.cc:552: Check failed: (schema.is\u003cpicojson::object\u003e()) is false: Schema should be an object or bool\\n', 'type': 'BadRequestError', 'param': None, 'code': 400}"} ### ❌ Actual Behavior _No response_
yindo added the 🐞 bug label 2026-02-21 20:07:58 -05:00
yindo closed this issue 2026-02-21 20:07:59 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Nov 26, 2025):

This is a known bug in Dify 2.0.0-beta2 and earlier, where the iteration node can trigger an AssertionError: this statement should be unreachable in variable_truncator.py when the truncation logic encounters unexpected data types—often custom objects or segments not handled by the truncator. This leads to system lag, model loading issues, and downstream JSON schema validation errors in workflows using iteration nodes. The root cause is that iteration node inputs (from ArraySegment.to_object()) may include non-primitive types, which the truncator does not support, causing the recursion to hit the unreachable assertion and break the workflow response pipeline. This is confirmed in several issues and discussions, and maintainers have acknowledged it as a known problem slated for resolution before the 2.0.0 release (source, source).

A recent fix was merged (PR #27484, 2025-10-27), introducing a DummyVariableTruncator that disables truncation for certain API calls, avoiding this error for those cases. To resolve the issue, upgrade to the latest Dify version after 2.0.0-beta2 or rebuild your Docker image from the main branch with recent fixes. If you cannot upgrade immediately, a workaround is to ensure all iteration node inputs and outputs are normalized or serialized to supported types (string, number, boolean, dict, list, or known file types) before they reach the truncator (source, source). Avoid passing custom objects or segments directly in iteration payloads.

If you need a temporary patch, you can extend _truncate_json_primitives to handle additional types or add normalization logic to iteration node outputs before truncation. However, upgrading is the recommended and most reliable solution.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

@dosubot[bot] commented on GitHub (Nov 26, 2025): <!-- Answer --> This is a known bug in Dify 2.0.0-beta2 and earlier, where the iteration node can trigger an `AssertionError: this statement should be unreachable` in `variable_truncator.py` when the truncation logic encounters unexpected data types—often custom objects or segments not handled by the truncator. This leads to system lag, model loading issues, and downstream JSON schema validation errors in workflows using iteration nodes. The root cause is that iteration node inputs (from `ArraySegment.to_object()`) may include non-primitive types, which the truncator does not support, causing the recursion to hit the unreachable assertion and break the workflow response pipeline. This is confirmed in several issues and discussions, and maintainers have acknowledged it as a known problem slated for resolution before the 2.0.0 release ([source](https://github.com/langgenius/dify/issues/25379), [source](https://github.com/langgenius/dify/discussions/27932)). A recent fix was merged ([PR #27484, 2025-10-27](https://github.com/langgenius/dify/pull/27484)), introducing a `DummyVariableTruncator` that disables truncation for certain API calls, avoiding this error for those cases. To resolve the issue, upgrade to the latest Dify version after 2.0.0-beta2 or rebuild your Docker image from the main branch with recent fixes. If you cannot upgrade immediately, a workaround is to ensure all iteration node inputs and outputs are normalized or serialized to supported types (string, number, boolean, dict, list, or known file types) before they reach the truncator ([source](https://github.com/langgenius/dify/discussions/27932), [source](https://github.com/langgenius/dify/blob/d696b9f35e125ef3f3cbbd630ed24bb6d3122c45/api/services/variable_truncator.py#L116-L432)). Avoid passing custom objects or segments directly in iteration payloads. If you need a temporary patch, you can extend `_truncate_json_primitives` to handle additional types or add normalization logic to iteration node outputs before truncation. However, upgrading is the recommended and most reliable solution. <!-- 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/d9c3a88b-e8cb-4e96-b0c4-d3ed4ac99159?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/d9c3a88b-e8cb-4e96-b0c4-d3ed4ac99159?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/d9c3a88b-e8cb-4e96-b0c4-d3ed4ac99159?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/d9c3a88b-e8cb-4e96-b0c4-d3ed4ac99159?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/d9c3a88b-e8cb-4e96-b0c4-d3ed4ac99159?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/d9c3a88b-e8cb-4e96-b0c4-d3ed4ac99159?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/d9c3a88b-e8cb-4e96-b0c4-d3ed4ac99159?feedback_type=other)</sup> [![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/6088a4f4-073a-43f3-b3d4-4f06fb0c05a0/ask?utm_source=github)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=This%20is%20a%20known%20bug%20in%20Dify%202.0.0-beta2%20and%20earlier%2C%20where%20the%20iteration%20node%20can%20trigger%20an%20%60AssertionError%3A%20this%20statement%20should%20be%20unreachable%60%20in%20%60variable_truncator.py%60%20when%20the%20truncation%20logic%20encounters%20unexpected%20data%20types%E2%80%94often%20custom%20objects%20or%20segments%20not%20handled%20by%20the%20truncator.%20This%20leads%20to%20system%20lag%2C%20model%20loading%20issues%2C%20and%20downstream%20JSON%20schema%20validation%20errors%20in%20workflows%20using%20iteration%20nodes.%20The%20root%20cause%20is%20that%20iteration%20node%20inputs%20%28from%20%60ArraySegment.to_object%28%29%60%29%20may%20include%20non-primitive%20types%2C%20which%20the%20truncator%20does%20not%20support%2C%20causing%20the%20recursion%20to%20hit%20the%20unreachable%20assertion%20and%20break%20the%20workflow%20response%20pipeline.%20This%20is%20confirmed%20in%20several%20issues%20and%20discussions%2C%20and%20maintainers%20have%20acknowledged%20it%20as%20a%20known%20problem%20slated%20for%20resolution%20before%20the%202.0.0%20release%20%28%5Bsource%5D%28https%3A//github.com/langgenius/dify/issues/25379%29%2C%20%5Bsource%5D%28https%3A//github.com/langgenius/dify/discussions/27932%29%29.%0A%0AA%20recent%20fix%20was%20merged%20%28%5BPR%20%2327484%2C%202025-10-27%5D%28https%3A//github.com/langgenius/dify/pull/27484%29%29%2C%20introducing%20a%20%60DummyVariableTruncator%60%20that%20disables%20truncation%20for%20certain%20API%20calls%2C%20avoiding%20this%20error%20for%20those%20cases.%20To%20resolve%20the%20issue%2C%20upgrade%20to%20the%20latest%20Dify%20version%20after%202.0.0-beta2%20or%20rebuild%20your%20Docker%20image%20from%20the%20main%20branch%20with%20recent%20fixes.%20If%20you%20cannot%20upgrade%20immediately%2C%20a%20workaround%20is%20to%20ensure%20all%20iteration%20node%20inputs%20and%20outputs%20are%20normalized%20or%20serialized%20to%20supported%20types%20%28string%2C%20number%2C%20boolean%2C%20dict%2C%20list%2C%20or%20known%20file%20types%29%20before%20they%20reach%20the%20truncator%20%28%5Bsource%5D%28https%3A//github.com/langgenius/dify/discussions/27932%29%2C%20%5Bsource%5D%28https%3A//github.com/langgenius/dify/blob/d696b9f35e125ef3f3cbbd630ed24bb6d3122c45/api/services/variable_truncator.py%23L116-L432%29%29.%20Avoid%20passing%20custom%20objects%20or%20segments%20directly%20in%20iteration%20payloads.%0A%0AIf%20you%20need%20a%20temporary%20patch%2C%20you%20can%20extend%20%60_truncate_json_primitives%60%20to%20handle%20additional%20types%20or%20add%20normalization%20logic%20to%20iteration%20node%20outputs%20before%20truncation.%20However%2C%20upgrading%20is%20the%20recommended%20and%20most%20reliable%20solution.)&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/28692)
Author
Owner

@userGuo-o commented on GitHub (Nov 26, 2025):

[2025-11-26 08:41:17 +0000] [29] [ERROR] Error handling request
Traceback (most recent call last):
File "/app/api/.venv/lib/python3.12/site-packages/gunicorn/workers/base_async.py", line 114, in handle_request
for item in respiter:
^^^^^^^^
File "/app/api/.venv/lib/python3.12/site-packages/werkzeug/wsgi.py", line 256, in next
return self._next()
^^^^^^^^^^^^
File "/app/api/.venv/lib/python3.12/site-packages/werkzeug/wrappers/response.py", line 32, in _iter_encoded
for item in iterable:
^^^^^^^^
File "/app/api/.venv/lib/python3.12/site-packages/flask/helpers.py", line 132, in generator
yield from gen
File "/app/api/libs/helper.py", line 214, in generate
yield from response
File "/app/api/core/app/features/rate_limiting/rate_limit.py", line 120, in next
return next(self.generator)
^^^^^^^^^^^^^^^^^^^^
File "/app/api/core/app/apps/base_app_generator.py", line 176, in gen
for message in generator:
^^^^^^^^^
File "/app/api/core/app/apps/base_app_generate_response_converter.py", line 27, in _generate_full_response
yield from cls.convert_stream_full_response(response)
File "/app/api/core/app/apps/workflow/generate_response_converter.py", line 46, in convert_stream_full_response
for chunk in stream_response:
^^^^^^^^^^^^^^^
File "/app/api/core/app/apps/workflow/generate_task_pipeline.py", line 190, in _to_stream_response
for stream_response in generator:
^^^^^^^^^
File "/app/api/core/app/apps/workflow/generate_task_pipeline.py", line 221, in _wrapper_process_stream_response
for response in self._process_stream_response(tts_publisher=tts_publisher, trace_manager=trace_manager):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/core/app/apps/workflow/generate_task_pipeline.py", line 686, in _process_stream_response
if responses := list(
^^^^^
File "/app/api/core/app/apps/workflow/generate_task_pipeline.py", line 615, in _dispatch_event
yield from handler(
File "/app/api/core/app/apps/workflow/generate_task_pipeline.py", line 373, in _handle_iteration_start_event
iter_start_resp = self._workflow_response_converter.workflow_iteration_start_to_stream_response(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/core/app/apps/common/workflow_response_converter.py", line 288, in workflow_iteration_start_to_stream_response
new_inputs, truncated = self._truncator.truncate_variable_mapping(event.inputs or {})
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/services/variable_truncator.py", line 150, in truncate_variable_mapping
part_result = self._truncate_json_primitives(value, value_budget)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/services/variable_truncator.py", line 413, in _truncate_json_primitives
return self._truncate_array(val, target_size)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/services/variable_truncator.py", line 298, in _truncate_array
part_result = self._truncate_json_primitives(item, target_size - used_size)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/services/variable_truncator.py", line 419, in _truncate_json_primitives
raise AssertionError("this statement should be unreachable.")
AssertionError: this statement should be unreachable.

@userGuo-o commented on GitHub (Nov 26, 2025): [2025-11-26 08:41:17 +0000] [29] [ERROR] Error handling request Traceback (most recent call last): File "/app/api/.venv/lib/python3.12/site-packages/gunicorn/workers/base_async.py", line 114, in handle_request for item in respiter: ^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/werkzeug/wsgi.py", line 256, in __next__ return self._next() ^^^^^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/werkzeug/wrappers/response.py", line 32, in _iter_encoded for item in iterable: ^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/flask/helpers.py", line 132, in generator yield from gen File "/app/api/libs/helper.py", line 214, in generate yield from response File "/app/api/core/app/features/rate_limiting/rate_limit.py", line 120, in __next__ return next(self.generator) ^^^^^^^^^^^^^^^^^^^^ File "/app/api/core/app/apps/base_app_generator.py", line 176, in gen for message in generator: ^^^^^^^^^ File "/app/api/core/app/apps/base_app_generate_response_converter.py", line 27, in _generate_full_response yield from cls.convert_stream_full_response(response) File "/app/api/core/app/apps/workflow/generate_response_converter.py", line 46, in convert_stream_full_response for chunk in stream_response: ^^^^^^^^^^^^^^^ File "/app/api/core/app/apps/workflow/generate_task_pipeline.py", line 190, in _to_stream_response for stream_response in generator: ^^^^^^^^^ File "/app/api/core/app/apps/workflow/generate_task_pipeline.py", line 221, in _wrapper_process_stream_response for response in self._process_stream_response(tts_publisher=tts_publisher, trace_manager=trace_manager): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/core/app/apps/workflow/generate_task_pipeline.py", line 686, in _process_stream_response if responses := list( ^^^^^ File "/app/api/core/app/apps/workflow/generate_task_pipeline.py", line 615, in _dispatch_event yield from handler( File "/app/api/core/app/apps/workflow/generate_task_pipeline.py", line 373, in _handle_iteration_start_event iter_start_resp = self._workflow_response_converter.workflow_iteration_start_to_stream_response( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/core/app/apps/common/workflow_response_converter.py", line 288, in workflow_iteration_start_to_stream_response new_inputs, truncated = self._truncator.truncate_variable_mapping(event.inputs or {}) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/services/variable_truncator.py", line 150, in truncate_variable_mapping part_result = self._truncate_json_primitives(value, value_budget) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/services/variable_truncator.py", line 413, in _truncate_json_primitives return self._truncate_array(val, target_size) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/services/variable_truncator.py", line 298, in _truncate_array part_result = self._truncate_json_primitives(item, target_size - used_size) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/services/variable_truncator.py", line 419, in _truncate_json_primitives raise AssertionError("this statement should be unreachable.") AssertionError: this statement should be unreachable.
Author
Owner

@userGuo-o commented on GitHub (Nov 26, 2025):

There is no problem with single branch processing files for multimodal models, and there is no problem with using String arrays for iterative workflows. There is an issue with iterating into the file array used as a reference. After checking the backend, it was found that the truncater ArraySegment. toobje() received an unprocessed primitive type. Before iterating the node, it is possible to handle file list iterations, but it is unclear which version was updated and which version caused the issue

@userGuo-o commented on GitHub (Nov 26, 2025): There is no problem with single branch processing files for multimodal models, and there is no problem with using String arrays for iterative workflows. There is an issue with iterating into the file array used as a reference. After checking the backend, it was found that the truncater ArraySegment. toobje() received an unprocessed primitive type. Before iterating the node, it is possible to handle file list iterations, but it is unclear which version was updated and which version caused the issue
Author
Owner

@crazywoola commented on GitHub (Nov 26, 2025):

This version is outdated, please switch to the latest version v1.10.1 instead. We will not fix the errors in this beta version any longer.

@crazywoola commented on GitHub (Nov 26, 2025): This version is outdated, please switch to the latest version v1.10.1 instead. We will not fix the errors in this beta version any longer.
Author
Owner

@userGuo-o commented on GitHub (Nov 26, 2025):

Can 2.0.0 beta directly switch to v1.10.1? The data structure seems to be different

@userGuo-o commented on GitHub (Nov 26, 2025): Can 2.0.0 beta directly switch to v1.10.1? The data structure seems to be different
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#20565