AttributeError: 'function' object has no attribute 'output' #12950

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

Originally created by @ronylee on GitHub (Apr 15, 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

1.2.0

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

2025-04-15 09:25:45.682 ERROR [Dummy-69] [app.py:875] - Exception on /v1/messages [GET]
Traceback (most recent call last):
File "/app/api/.venv/lib/python3.12/site-packages/flask/app.py", line 917, in full_dispatch_request
rv = self.dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^
File "/app/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 "/app/api/.venv/lib/python3.12/site-packages/flask_restful/__init__.py", line 489, in wrapper
resp = resource(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/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 "/app/api/.venv/lib/python3.12/site-packages/flask_restful/__init__.py", line 604, in dispatch_request
resp = meth(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/app/api/controllers/service_api/wraps.py", line 104, in decorated_view
return view_func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/.venv/lib/python3.12/site-packages/flask_restful/__init__.py", line 701, in wrapper
return marshal(resp, self.fields, self.envelope)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/.venv/lib/python3.12/site-packages/flask_restful/__init__.py", line 657, in marshal
return OrderedDict([(envelope, OrderedDict(items))]) if envelope else OrderedDict(items)
^^^^^^^^^^^^^^^^^^
File "/app/api/.venv/lib/python3.12/site-packages/flask_restful/__init__.py", line 655, in
else make(v).output(k, data))
^^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/.venv/lib/python3.12/site-packages/flask_restful/fields.py", line 197, in output
return self.format(value)
^^^^^^^^^^^^^^^^^^
File "/app/api/.venv/lib/python3.12/site-packages/flask_restful/fields.py", line 183, in format
self.container.output(idx,
File "/app/api/.venv/lib/python3.12/site-packages/flask_restful/fields.py", line 152, in output
return marshal(value, self.nested)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/.venv/lib/python3.12/site-packages/flask_restful/__init__.py", line 657, in marshal
return OrderedDict([(envelope, OrderedDict(items))]) if envelope else OrderedDict(items)
^^^^^^^^^^^^^^^^^^
File "/app/api/.venv/lib/python3.12/site-packages/flask_restful/__init__.py", line 655, in
else make(v).output(k, data))
^^^^^^^^^^^^^^
AttributeError: 'function' object has no attribute 'output'

/v1/messages API error

✔️ Expected Behavior

No response

Actual Behavior

No response

Originally created by @ronylee on GitHub (Apr 15, 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 1.2.0 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce 2025-04-15 09:25:45.682 ERROR [Dummy-69] [app.py:875] - Exception on /v1/messages [GET] Traceback (most recent call last): File "/app/api/.venv/lib/python3.12/site-packages/flask/app.py", line 917, in full_dispatch_request rv = self.dispatch_request() ^^^^^^^^^^^^^^^^^^^^^^^ File "/app/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 "/app/api/.venv/lib/python3.12/site-packages/flask_restful/__init__.py", line 489, in wrapper resp = resource(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/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 "/app/api/.venv/lib/python3.12/site-packages/flask_restful/__init__.py", line 604, in dispatch_request resp = meth(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/app/api/controllers/service_api/wraps.py", line 104, in decorated_view return view_func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/flask_restful/__init__.py", line 701, in wrapper return marshal(resp, self.fields, self.envelope) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/flask_restful/__init__.py", line 657, in marshal return OrderedDict([(envelope, OrderedDict(items))]) if envelope else OrderedDict(items) ^^^^^^^^^^^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/flask_restful/__init__.py", line 655, in <genexpr> else make(v).output(k, data)) ^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/flask_restful/fields.py", line 197, in output return self.format(value) ^^^^^^^^^^^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/flask_restful/fields.py", line 183, in format self.container.output(idx, File "/app/api/.venv/lib/python3.12/site-packages/flask_restful/fields.py", line 152, in output return marshal(value, self.nested) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/flask_restful/__init__.py", line 657, in marshal return OrderedDict([(envelope, OrderedDict(items))]) if envelope else OrderedDict(items) ^^^^^^^^^^^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/flask_restful/__init__.py", line 655, in <genexpr> else make(v).output(k, data)) ^^^^^^^^^^^^^^ AttributeError: 'function' object has no attribute 'output' /v1/messages API error ### ✔️ Expected Behavior _No response_ ### ❌ Actual Behavior _No response_
yindo added the 🐞 bug label 2026-02-21 19:09:50 -05:00
yindo closed this issue 2026-02-21 19:09:50 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Apr 15, 2025):

Hello @ronylee! I'm Dosu, your friendly bot here to help you solve bugs, answer questions, and assist you in becoming a contributor. I'm here to support you while you wait for a human maintainer. How can I assist you today?

To resolve the "AttributeError: 'function' object has no attribute 'output'" error in the /v1/messages API for Dify version 1.2.0, you can try the following solutions:

  1. Use the alternative endpoint /v1/chat-messages instead of /v1/messages [1].

  2. Apply a code modification in your Docker container. Update the code in api/controllers/service_api/app/message.py by replacing:

    "retriever_resources": fields.Raw(
        attribute=lambda obj: json.loads(obj.message_metadata).get("retriever_resources", [])
        if obj.message_metadata
        else []
    )
    

    with:

    "retriever_resources": fields.List(fields.String, attribute=lambda x: json.loads(x.message_metadata).get("retriever_resources", []), default=[]),
    

    After making this change, restart the API container using:

    docker compose restart api
    

These steps should help resolve the issue you're encountering [2].

To continue talking to Dosu, mention @dosu.


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

@dosubot[bot] commented on GitHub (Apr 15, 2025): <!-- Greeting --> Hello @ronylee! I'm [Dosu](https://dosu.dev), your friendly bot here to help you solve bugs, answer questions, and assist you in becoming a contributor. I'm here to support you while you wait for a human maintainer. How can I assist you today? <!-- Answer --> To resolve the "AttributeError: 'function' object has no attribute 'output'" error in the `/v1/messages` API for Dify version 1.2.0, you can try the following solutions: 1. Use the alternative endpoint `/v1/chat-messages` instead of `/v1/messages` <sup>[[1]](https://github.com/langgenius/dify/issues/17983)</sup>. 2. Apply a code modification in your Docker container. Update the code in `api/controllers/service_api/app/message.py` by replacing: ```python "retriever_resources": fields.Raw( attribute=lambda obj: json.loads(obj.message_metadata).get("retriever_resources", []) if obj.message_metadata else [] ) ``` with: ```python "retriever_resources": fields.List(fields.String, attribute=lambda x: json.loads(x.message_metadata).get("retriever_resources", []), default=[]), ``` After making this change, restart the API container using: ```bash docker compose restart api ``` These steps should help resolve the issue you're encountering <sup>[[2]](https://github.com/langgenius/dify/issues/18056)</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/12828fdd-1e83-4dbc-8b91-824fc0a0639f?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/12828fdd-1e83-4dbc-8b91-824fc0a0639f?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/12828fdd-1e83-4dbc-8b91-824fc0a0639f?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/12828fdd-1e83-4dbc-8b91-824fc0a0639f?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/12828fdd-1e83-4dbc-8b91-824fc0a0639f?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/12828fdd-1e83-4dbc-8b91-824fc0a0639f?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/12828fdd-1e83-4dbc-8b91-824fc0a0639f?feedback_type=other)</sup>
Author
Owner

@ronylee commented on GitHub (Apr 15, 2025):

The issue was resolved by downgrading the Python version to 3.11 in the API container. This fix should be included in upcoming releases.

@ronylee commented on GitHub (Apr 15, 2025): The issue was resolved by downgrading the Python version to 3.11 in the API container. This fix should be included in upcoming releases.
Author
Owner

@crazywoola commented on GitHub (Apr 15, 2025):

@crazywoola commented on GitHub (Apr 15, 2025): -
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#12950