[API] An error occurred in the messages interface #12924

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

Originally created by @yuntong613 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

When an error occurs when calling the messages interface, the conversation_id comes from the conversations interface

2025-04-15 06:54:47.713 ERROR [Dummy-688] [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'

✔️ Expected Behavior

No response

Actual Behavior

No response

Originally created by @yuntong613 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 When an error occurs when calling the messages interface, the conversation_id comes from the conversations interface ` 2025-04-15 06:54:47.713 ERROR [Dummy-688] [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'` ### ✔️ Expected Behavior _No response_ ### ❌ Actual Behavior _No response_
yindo closed this issue 2026-02-21 19:09:42 -05:00
Author
Owner

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

I found a similar issue that was resolved. The "AttributeError: 'function' object has no attribute 'output'" error in Dify version 1.2.0 can be addressed by:

  1. Using the alternative endpoint /v1/chat-messages instead of /v1/messages.

  2. Modifying the code in api/controllers/service_api/app/message.py by replacing:

    "retriever_resources": get_retriever_resources,
    

    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 [1].

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): <!-- Answer --> I found a similar issue that was resolved. The "AttributeError: 'function' object has no attribute 'output'" error in Dify version 1.2.0 can be addressed by: 1. Using the alternative endpoint `/v1/chat-messages` instead of `/v1/messages`. 2. Modifying the code in `api/controllers/service_api/app/message.py` by replacing: ```python "retriever_resources": get_retriever_resources, ``` 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>[[1]](https://github.com/langgenius/dify/issues/17805)</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/bb72add3-3774-4fd2-9375-2cd1baf3e764?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/bb72add3-3774-4fd2-9375-2cd1baf3e764?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/bb72add3-3774-4fd2-9375-2cd1baf3e764?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/bb72add3-3774-4fd2-9375-2cd1baf3e764?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/bb72add3-3774-4fd2-9375-2cd1baf3e764?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/bb72add3-3774-4fd2-9375-2cd1baf3e764?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/bb72add3-3774-4fd2-9375-2cd1baf3e764?feedback_type=other)</sup>
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#12924