draft run any nodes raise http500 #20537

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

Originally created by @hjlarry on GitHub (Nov 25, 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

latest main branch

Cloud or Self Hosted

Self Hosted (Source)

Steps to reproduce

  1. create a workflow
  2. draft run any single nodes

error log:

2025-11-25 07:56:27,95 ERROR [app.py:875] e72df4144b Exception on /console/api/apps/968046a9-17db-416a-ad7f-19278dfcb959/workflows/draft/nodes/1764056785260/last-run [GET]
Traceback (most recent call last):
  File "/Users/hejl/projects/dify/api/.venv/lib/python3.12/site-packages/flask/app.py", line 917, in full_dispatch_request
    rv = self.dispatch_request()
         ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hejl/projects/dify/api/.venv/lib/python3.12/site-packages/flask/app.py", line 902, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hejl/projects/dify/api/.venv/lib/python3.12/site-packages/flask_restx/api.py", line 404, in wrapper
    resp = resource(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hejl/projects/dify/api/.venv/lib/python3.12/site-packages/flask/views.py", line 110, in view
    return current_app.ensure_sync(self.dispatch_request)(**kwargs)  # type: ignore[no-any-return]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hejl/projects/dify/api/.venv/lib/python3.12/site-packages/flask_restx/resource.py", line 41, in dispatch_request
    resp = meth(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hejl/projects/dify/api/controllers/console/wraps.py", line 220, in decorated
    return view(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hejl/projects/dify/api/libs/login.py", line 80, in decorated_view
    return current_app.ensure_sync(func)(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hejl/projects/dify/api/controllers/console/wraps.py", line 37, in decorated
    return view(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hejl/projects/dify/api/controllers/console/app/wraps.py", line 57, in decorated_view
    return view_func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hejl/projects/dify/api/.venv/lib/python3.12/site-packages/flask_restx/marshalling.py", line 266, in wrapper
    return marshal(
           ^^^^^^^^
  File "/Users/hejl/projects/dify/api/.venv/lib/python3.12/site-packages/flask_restx/marshalling.py", line 54, in marshal
    out, has_wildcards = _marshal(data, fields, envelope, skip_none, mask, ordered)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hejl/projects/dify/api/.venv/lib/python3.12/site-packages/flask_restx/marshalling.py", line 179, in _marshal
    for k, v in fields.items()
                ^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'items'
2025-11-25 07:56:27,140 INFO [_internal.py:97]  127.0.0.1 - - [25/Nov/2025 07:56:27] "GET /console/api/apps/968046a9-17db-416a-ad7f-19278dfcb959/workflows/draft/nodes/1764056785260/last-run HTTP/1.1" 500 

It may caused by this PR https://github.com/langgenius/dify/pull/28509

✔️ Expected Behavior

not raise exception

Actual Behavior

No response

Originally created by @hjlarry on GitHub (Nov 25, 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 latest main branch ### Cloud or Self Hosted Self Hosted (Source) ### Steps to reproduce 1. create a workflow 2. draft run any single nodes error log: ``` 2025-11-25 07:56:27,95 ERROR [app.py:875] e72df4144b Exception on /console/api/apps/968046a9-17db-416a-ad7f-19278dfcb959/workflows/draft/nodes/1764056785260/last-run [GET] Traceback (most recent call last): File "/Users/hejl/projects/dify/api/.venv/lib/python3.12/site-packages/flask/app.py", line 917, in full_dispatch_request rv = self.dispatch_request() ^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/hejl/projects/dify/api/.venv/lib/python3.12/site-packages/flask/app.py", line 902, in dispatch_request return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/hejl/projects/dify/api/.venv/lib/python3.12/site-packages/flask_restx/api.py", line 404, in wrapper resp = resource(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/hejl/projects/dify/api/.venv/lib/python3.12/site-packages/flask/views.py", line 110, in view return current_app.ensure_sync(self.dispatch_request)(**kwargs) # type: ignore[no-any-return] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/hejl/projects/dify/api/.venv/lib/python3.12/site-packages/flask_restx/resource.py", line 41, in dispatch_request resp = meth(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/Users/hejl/projects/dify/api/controllers/console/wraps.py", line 220, in decorated return view(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/Users/hejl/projects/dify/api/libs/login.py", line 80, in decorated_view return current_app.ensure_sync(func)(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/hejl/projects/dify/api/controllers/console/wraps.py", line 37, in decorated return view(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/Users/hejl/projects/dify/api/controllers/console/app/wraps.py", line 57, in decorated_view return view_func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/hejl/projects/dify/api/.venv/lib/python3.12/site-packages/flask_restx/marshalling.py", line 266, in wrapper return marshal( ^^^^^^^^ File "/Users/hejl/projects/dify/api/.venv/lib/python3.12/site-packages/flask_restx/marshalling.py", line 54, in marshal out, has_wildcards = _marshal(data, fields, envelope, skip_none, mask, ordered) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/hejl/projects/dify/api/.venv/lib/python3.12/site-packages/flask_restx/marshalling.py", line 179, in _marshal for k, v in fields.items() ^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'items' 2025-11-25 07:56:27,140 INFO [_internal.py:97] 127.0.0.1 - - [25/Nov/2025 07:56:27] "GET /console/api/apps/968046a9-17db-416a-ad7f-19278dfcb959/workflows/draft/nodes/1764056785260/last-run HTTP/1.1" 500 ``` It may caused by this PR https://github.com/langgenius/dify/pull/28509 ### ✔️ Expected Behavior not raise exception ### ❌ Actual Behavior _No response_
yindo added the 🐞 bug label 2026-02-21 20:07:52 -05:00
yindo closed this issue 2026-02-21 20:07:52 -05:00
Author
Owner

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

The root cause is that the model registration for workflow_run_node_execution_model uses console_ns.models.get(...), which returns None if the model hasn't been registered yet. If this happens, the @marshal_with decorator receives None for its fields argument, causing the AttributeError: 'NoneType' object has no attribute 'items' during marshalling in Flask-RESTx. This pattern was introduced or exposed by changes in PR #28509, which refactored API schema registration to use registered models everywhere.

To fix this, update the registration logic so that if console_ns.models.get("WorkflowRunNodeExecution") returns None, you explicitly register the model:

workflow_run_node_execution_model = console_ns.models.get("WorkflowRunNodeExecution")
if workflow_run_node_execution_model is None:
    workflow_run_node_execution_model = console_ns.model("WorkflowRunNodeExecution", workflow_run_node_execution_fields)

This ensures the model is always valid for marshalling and prevents the 500 error. It's a good idea to check for similar registration patterns in other endpoints and update them as well to avoid the same issue in the future.

You can see the relevant code and explanation here.

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 25, 2025): <!-- Answer --> The root cause is that the model registration for `workflow_run_node_execution_model` uses `console_ns.models.get(...)`, which returns `None` if the model hasn't been registered yet. If this happens, the `@marshal_with` decorator receives `None` for its fields argument, causing the `AttributeError: 'NoneType' object has no attribute 'items'` during marshalling in Flask-RESTx. This pattern was introduced or exposed by changes in PR #28509, which refactored API schema registration to use registered models everywhere. To fix this, update the registration logic so that if `console_ns.models.get("WorkflowRunNodeExecution")` returns `None`, you explicitly register the model: ```python workflow_run_node_execution_model = console_ns.models.get("WorkflowRunNodeExecution") if workflow_run_node_execution_model is None: workflow_run_node_execution_model = console_ns.model("WorkflowRunNodeExecution", workflow_run_node_execution_fields) ``` This ensures the model is always valid for marshalling and prevents the 500 error. It's a good idea to check for similar registration patterns in other endpoints and update them as well to avoid the same issue in the future. You can see the relevant code and explanation [here](https://github.com/langgenius/dify/blob/57b405c4c2724b63be8b82525a23c1575db26aef/api/controllers/console/app/workflow.py#L98-L1004). <!-- 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/ad6ed9d4-062c-457e-b6cc-ac2fb27b71ef?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/ad6ed9d4-062c-457e-b6cc-ac2fb27b71ef?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/ad6ed9d4-062c-457e-b6cc-ac2fb27b71ef?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/ad6ed9d4-062c-457e-b6cc-ac2fb27b71ef?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/ad6ed9d4-062c-457e-b6cc-ac2fb27b71ef?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/ad6ed9d4-062c-457e-b6cc-ac2fb27b71ef?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/ad6ed9d4-062c-457e-b6cc-ac2fb27b71ef?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=The%20root%20cause%20is%20that%20the%20model%20registration%20for%20%60workflow_run_node_execution_model%60%20uses%20%60console_ns.models.get%28...%29%60%2C%20which%20returns%20%60None%60%20if%20the%20model%20hasn%27t%20been%20registered%20yet.%20If%20this%20happens%2C%20the%20%60%40marshal_with%60%20decorator%20receives%20%60None%60%20for%20its%20fields%20argument%2C%20causing%20the%20%60AttributeError%3A%20%27NoneType%27%20object%20has%20no%20attribute%20%27items%27%60%20during%20marshalling%20in%20Flask-RESTx.%20This%20pattern%20was%20introduced%20or%20exposed%20by%20changes%20in%20PR%20%2328509%2C%20which%20refactored%20API%20schema%20registration%20to%20use%20registered%20models%20everywhere.%0A%0ATo%20fix%20this%2C%20update%20the%20registration%20logic%20so%20that%20if%20%60console_ns.models.get%28%22WorkflowRunNodeExecution%22%29%60%20returns%20%60None%60%2C%20you%20explicitly%20register%20the%20model%3A%0A%0A%60%60%60python%0Aworkflow_run_node_execution_model%20%3D%20console_ns.models.get%28%22WorkflowRunNodeExecution%22%29%0Aif%20workflow_run_node_execution_model%20is%20None%3A%0A%20%20%20%20workflow_run_node_execution_model%20%3D%20console_ns.model%28%22WorkflowRunNodeExecution%22%2C%20workflow_run_node_execution_fields%29%0A%60%60%60%0A%0AThis%20ensures%20the%20model%20is%20always%20valid%20for%20marshalling%20and%20prevents%20the%20500%20error.%20It%27s%20a%20good%20idea%20to%20check%20for%20similar%20registration%20patterns%20in%20other%20endpoints%20and%20update%20them%20as%20well%20to%20avoid%20the%20same%20issue%20in%20the%20future.%20%0A%0AYou%20can%20see%20the%20relevant%20code%20and%20explanation%20%5Bhere%5D%28https%3A//github.com/langgenius/dify/blob/57b405c4c2724b63be8b82525a23c1575db26aef/api/controllers/console/app/workflow.py%23L98-L1004%29.)&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/28635)
Author
Owner

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

The root cause is that the model registration for workflow_run_node_execution_model uses console_ns.models.get(...), which returns None if the model hasn't been registered yet. If this happens, the @marshal_with decorator receives None for its fields argument, causing the AttributeError: 'NoneType' object has no attribute 'items' during marshalling in Flask-RESTx. This pattern was introduced or exposed by changes in PR #28509, which refactored API schema registration to use registered models everywhere.

To fix this, update the registration logic so that if console_ns.models.get("WorkflowRunNodeExecution") returns None, you explicitly register the model:

workflow_run_node_execution_model = console_ns.models.get("WorkflowRunNodeExecution")
if workflow_run_node_execution_model is None:
workflow_run_node_execution_model = console_ns.model("WorkflowRunNodeExecution", workflow_run_node_execution_fields)
This ensures the model is always valid for marshalling and prevents the 500 error. It's a good idea to check for similar registration patterns in other endpoints and update them as well to avoid the same issue in the future.

You can see the relevant code and explanation here.

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

I checked it and found that the problem seems to be only in this one place.

@changkeke commented on GitHub (Nov 26, 2025): > The root cause is that the model registration for `workflow_run_node_execution_model` uses `console_ns.models.get(...)`, which returns `None` if the model hasn't been registered yet. If this happens, the `@marshal_with` decorator receives `None` for its fields argument, causing the `AttributeError: 'NoneType' object has no attribute 'items'` during marshalling in Flask-RESTx. This pattern was introduced or exposed by changes in PR [#28509](https://github.com/langgenius/dify/pull/28509), which refactored API schema registration to use registered models everywhere. > > To fix this, update the registration logic so that if `console_ns.models.get("WorkflowRunNodeExecution")` returns `None`, you explicitly register the model: > > workflow_run_node_execution_model = console_ns.models.get("WorkflowRunNodeExecution") > if workflow_run_node_execution_model is None: > workflow_run_node_execution_model = console_ns.model("WorkflowRunNodeExecution", workflow_run_node_execution_fields) > This ensures the model is always valid for marshalling and prevents the 500 error. It's a good idea to check for similar registration patterns in other endpoints and update them as well to avoid the same issue in the future. > > You can see the relevant code and explanation [here](https://github.com/langgenius/dify/blob/57b405c4c2724b63be8b82525a23c1575db26aef/api/controllers/console/app/workflow.py#L98-L1004). > > _To reply, just mention [@dosu](https://go.dosu.dev/dosubot)._ > > How did I do? [Good](https://app.dosu.dev/response-feedback/ad6ed9d4-062c-457e-b6cc-ac2fb27b71ef?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/ad6ed9d4-062c-457e-b6cc-ac2fb27b71ef?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/ad6ed9d4-062c-457e-b6cc-ac2fb27b71ef?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/ad6ed9d4-062c-457e-b6cc-ac2fb27b71ef?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/ad6ed9d4-062c-457e-b6cc-ac2fb27b71ef?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/ad6ed9d4-062c-457e-b6cc-ac2fb27b71ef?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/ad6ed9d4-062c-457e-b6cc-ac2fb27b71ef?feedback_type=other) > > [![Chat with Dosu](https://camo.githubusercontent.com/7c571478962a6b8a5d47cac74b6824c75e4f6731bba52377e6007f9150462923/68747470733a2f2f646f73752e6465762f646f73752d636861742d62616467652e737667)](https://app.dosu.dev/6088a4f4-073a-43f3-b3d4-4f06fb0c05a0/ask?utm_source=github) [![Open in Cursor](https://camo.githubusercontent.com/bdf7dbded65ee585887f47e5fd6fa099ea0933088b4b03d02e83b4def50154d4/68747470733a2f2f646f73752e6465762f646f73752d696e2d637572736f722e737667)](https://cursor.com/link/prompt?text=The%20root%20cause%20is%20that%20the%20model%20registration%20for%20%60workflow_run_node_execution_model%60%20uses%20%60console_ns.models.get%28...%29%60%2C%20which%20returns%20%60None%60%20if%20the%20model%20hasn%27t%20been%20registered%20yet.%20If%20this%20happens%2C%20the%20%60%40marshal_with%60%20decorator%20receives%20%60None%60%20for%20its%20fields%20argument%2C%20causing%20the%20%60AttributeError%3A%20%27NoneType%27%20object%20has%20no%20attribute%20%27items%27%60%20during%20marshalling%20in%20Flask-RESTx.%20This%20pattern%20was%20introduced%20or%20exposed%20by%20changes%20in%20PR%20%2328509%2C%20which%20refactored%20API%20schema%20registration%20to%20use%20registered%20models%20everywhere.%0A%0ATo%20fix%20this%2C%20update%20the%20registration%20logic%20so%20that%20if%20%60console_ns.models.get%28%22WorkflowRunNodeExecution%22%29%60%20returns%20%60None%60%2C%20you%20explicitly%20register%20the%20model%3A%0A%0A%60%60%60python%0Aworkflow_run_node_execution_model%20%3D%20console_ns.models.get%28%22WorkflowRunNodeExecution%22%29%0Aif%20workflow_run_node_execution_model%20is%20None%3A%0A%20%20%20%20workflow_run_node_execution_model%20%3D%20console_ns.model%28%22WorkflowRunNodeExecution%22%2C%20workflow_run_node_execution_fields%29%0A%60%60%60%0A%0AThis%20ensures%20the%20model%20is%20always%20valid%20for%20marshalling%20and%20prevents%20the%20500%20error.%20It%27s%20a%20good%20idea%20to%20check%20for%20similar%20registration%20patterns%20in%20other%20endpoints%20and%20update%20them%20as%20well%20to%20avoid%20the%20same%20issue%20in%20the%20future.%20%0A%0AYou%20can%20see%20the%20relevant%20code%20and%20explanation%20%5Bhere%5D%28https%3A//github.com/langgenius/dify/blob/57b405c4c2724b63be8b82525a23c1575db26aef/api/controllers/console/app/workflow.py%23L98-L1004%29.) [![Join Discord](https://camo.githubusercontent.com/7d2066700925db1e370d956834f9ea0e5bc92cecbe84963fbd2a363e45091b4e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6a6f696e2d3538363546323f6c6f676f3d646973636f7264266c6f676f436f6c6f723d7768697465266c6162656c3d)](https://go.dosu.dev/discord-bot) [![Share on X](https://camo.githubusercontent.com/a8bd7f3fcf3f5e3bd124eee9ae50ae2ac17b40971726665ac2121d48f9aee155/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f582d73686172652d626c61636b)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify/issues/28635) I checked it and found that the problem seems to be only in this one place.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#20537