When upgrading from 1.1.3 to 1.2.0, the messages api reported 500 INTERNAL SERVER ERROR #12787

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

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

use messages api:
/messages?conversation_id=ee858a2d-bbaa-4a34-a622-4f7a36afd757&user=1

✔️ Expected Behavior

Expect a correct response like the one below:

{
    "limit": 10,
    "has_more": false,
    "data": [
        {
            "id": "923054ce-6cbc-4cdd-b3ba-9e7289e70777",
            "conversation_id": "5898def6-91fc-4218-8635-88b4e1f0d5ae",
            "inputs": {
                "docs": null
            },
            "query": "你是什么模型",
            "message": "",
            "message_tokens": 11,
            "answer": "我是 **DeepSeek Chat**,由 **深度求索(DeepSeek)** 公司研发的大语言模型(LLM)。我的最新版本是 **DeepSeek-V3**,知识更新至 **2024年7月**,具备强大的自然语言理解和生成能力,支持 **128K 上下文窗口**,能够处理长文档和复杂对话。  \n\n### 我的主要功能包括:\n✅ **信息问答**:提供准确的知识解答  \n✅ **文本处理**:写作、翻译、润色、总结等  \n✅ **代码辅助**:支持多种编程语言的代码生成与解释  \n✅ **文件分析**:支持 **PDF、Word、Excel、PPT、TXT** 等文件阅读  \n✅ **逻辑推理**:帮助解决数学、逻辑推理等问题  \n\n我是 **免费** 的,不联网时基于已有知识回答问题。如果你需要更实时的信息,可以手动开启 **联网搜索** 功能。  \n\n有什么我可以帮你的吗?😊",
            "answer_tokens": 206,
            "provider_response_latency": 17.10834017399975,
            "from_source": "api",
            "from_end_user_id": "7391bf46-b7ad-4f2a-854e-1c99c9731af7",
            "from_account_id": null,
            "feedbacks": [],
            "workflow_run_id": "24b518bd-ea2c-4424-ab92-6fb3f8800c95",
            "annotation": null,
            "annotation_hit_history": null,
            "created_at": 1744338384,
            "agent_thoughts": [],
            "message_files": [],
            "metadata": {},
            "status": "normal",
            "error": null,
            "parent_message_id": "00000000-0000-0000-0000-000000000000"
        }
    ]
}

Actual Behavior

{
    "message": "Internal Server Error",
    "code": "unknown"
}

api container error message:

2025-04-11 10:29:44.986 | 2025-04-11 02:29:44.983 ERROR [Dummy-35] [app.py:875] - Exception on /v1/messages [GET]
2025-04-11 10:29:44.986 | Traceback (most recent call last):
2025-04-11 10:29:44.986 |   File "/app/api/.venv/lib/python3.12/site-packages/flask/app.py", line 917, in full_dispatch_request
2025-04-11 10:29:44.986 |     rv = self.dispatch_request()
2025-04-11 10:29:44.986 |          ^^^^^^^^^^^^^^^^^^^^^^^
2025-04-11 10:29:44.986 |   File "/app/api/.venv/lib/python3.12/site-packages/flask/app.py", line 902, in dispatch_request
2025-04-11 10:29:44.986 |     return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]
2025-04-11 10:29:44.986 |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-04-11 10:29:44.986 |   File "/app/api/.venv/lib/python3.12/site-packages/flask_restful/__init__.py", line 489, in wrapper
2025-04-11 10:29:44.986 |     resp = resource(*args, **kwargs)
2025-04-11 10:29:44.986 |            ^^^^^^^^^^^^^^^^^^^^^^^^^
2025-04-11 10:29:44.986 |   File "/app/api/.venv/lib/python3.12/site-packages/flask/views.py", line 110, in view
2025-04-11 10:29:44.986 |     return current_app.ensure_sync(self.dispatch_request)(**kwargs)  # type: ignore[no-any-return]
2025-04-11 10:29:44.986 |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-04-11 10:29:44.986 |   File "/app/api/.venv/lib/python3.12/site-packages/flask_restful/__init__.py", line 604, in dispatch_request
2025-04-11 10:29:44.986 |     resp = meth(*args, **kwargs)
2025-04-11 10:29:44.986 |            ^^^^^^^^^^^^^^^^^^^^^
2025-04-11 10:29:44.986 |   File "/app/api/controllers/service_api/wraps.py", line 104, in decorated_view
2025-04-11 10:29:44.986 |     return view_func(*args, **kwargs)
2025-04-11 10:29:44.986 |            ^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-04-11 10:29:44.986 |   File "/app/api/.venv/lib/python3.12/site-packages/flask_restful/__init__.py", line 701, in wrapper
2025-04-11 10:29:44.986 |     return marshal(resp, self.fields, self.envelope)
2025-04-11 10:29:44.986 |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-04-11 10:29:44.986 |   File "/app/api/.venv/lib/python3.12/site-packages/flask_restful/__init__.py", line 657, in marshal
2025-04-11 10:29:44.986 |     return OrderedDict([(envelope, OrderedDict(items))]) if envelope else OrderedDict(items)
2025-04-11 10:29:44.986 |                                                                           ^^^^^^^^^^^^^^^^^^
2025-04-11 10:29:44.986 |   File "/app/api/.venv/lib/python3.12/site-packages/flask_restful/__init__.py", line 655, in <genexpr>
2025-04-11 10:29:44.986 |     else make(v).output(k, data))
2025-04-11 10:29:44.986 |          ^^^^^^^^^^^^^^^^^^^^^^^
2025-04-11 10:29:44.986 |   File "/app/api/.venv/lib/python3.12/site-packages/flask_restful/fields.py", line 197, in output
2025-04-11 10:29:44.986 |     return self.format(value)
2025-04-11 10:29:44.986 |            ^^^^^^^^^^^^^^^^^^
2025-04-11 10:29:44.986 |   File "/app/api/.venv/lib/python3.12/site-packages/flask_restful/fields.py", line 183, in format
2025-04-11 10:29:44.986 |     self.container.output(idx,
2025-04-11 10:29:44.986 |   File "/app/api/.venv/lib/python3.12/site-packages/flask_restful/fields.py", line 152, in output
2025-04-11 10:29:44.986 |     return marshal(value, self.nested)
2025-04-11 10:29:44.986 |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-04-11 10:29:44.986 |   File "/app/api/.venv/lib/python3.12/site-packages/flask_restful/__init__.py", line 657, in marshal
2025-04-11 10:29:44.986 |     return OrderedDict([(envelope, OrderedDict(items))]) if envelope else OrderedDict(items)
2025-04-11 10:29:44.986 |                                                                           ^^^^^^^^^^^^^^^^^^
2025-04-11 10:29:44.986 |   File "/app/api/.venv/lib/python3.12/site-packages/flask_restful/__init__.py", line 655, in <genexpr>
2025-04-11 10:29:44.986 |     else make(v).output(k, data))
2025-04-11 10:29:44.986 |          ^^^^^^^^^^^^^^
2025-04-11 10:29:44.986 | AttributeError: 'function' object has no attribute 'output'
Originally created by @leslieeilsel on GitHub (Apr 10, 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 use messages api: /messages?conversation_id=ee858a2d-bbaa-4a34-a622-4f7a36afd757&user=1 ### ✔️ Expected Behavior Expect a correct response like the one below: ```json { "limit": 10, "has_more": false, "data": [ { "id": "923054ce-6cbc-4cdd-b3ba-9e7289e70777", "conversation_id": "5898def6-91fc-4218-8635-88b4e1f0d5ae", "inputs": { "docs": null }, "query": "你是什么模型", "message": "", "message_tokens": 11, "answer": "我是 **DeepSeek Chat**,由 **深度求索(DeepSeek)** 公司研发的大语言模型(LLM)。我的最新版本是 **DeepSeek-V3**,知识更新至 **2024年7月**,具备强大的自然语言理解和生成能力,支持 **128K 上下文窗口**,能够处理长文档和复杂对话。 \n\n### 我的主要功能包括:\n✅ **信息问答**:提供准确的知识解答 \n✅ **文本处理**:写作、翻译、润色、总结等 \n✅ **代码辅助**:支持多种编程语言的代码生成与解释 \n✅ **文件分析**:支持 **PDF、Word、Excel、PPT、TXT** 等文件阅读 \n✅ **逻辑推理**:帮助解决数学、逻辑推理等问题 \n\n我是 **免费** 的,不联网时基于已有知识回答问题。如果你需要更实时的信息,可以手动开启 **联网搜索** 功能。 \n\n有什么我可以帮你的吗?😊", "answer_tokens": 206, "provider_response_latency": 17.10834017399975, "from_source": "api", "from_end_user_id": "7391bf46-b7ad-4f2a-854e-1c99c9731af7", "from_account_id": null, "feedbacks": [], "workflow_run_id": "24b518bd-ea2c-4424-ab92-6fb3f8800c95", "annotation": null, "annotation_hit_history": null, "created_at": 1744338384, "agent_thoughts": [], "message_files": [], "metadata": {}, "status": "normal", "error": null, "parent_message_id": "00000000-0000-0000-0000-000000000000" } ] } ``` ### ❌ Actual Behavior ```json { "message": "Internal Server Error", "code": "unknown" } ``` api container error message: ``` 2025-04-11 10:29:44.986 | 2025-04-11 02:29:44.983 ERROR [Dummy-35] [app.py:875] - Exception on /v1/messages [GET] 2025-04-11 10:29:44.986 | Traceback (most recent call last): 2025-04-11 10:29:44.986 | File "/app/api/.venv/lib/python3.12/site-packages/flask/app.py", line 917, in full_dispatch_request 2025-04-11 10:29:44.986 | rv = self.dispatch_request() 2025-04-11 10:29:44.986 | ^^^^^^^^^^^^^^^^^^^^^^^ 2025-04-11 10:29:44.986 | File "/app/api/.venv/lib/python3.12/site-packages/flask/app.py", line 902, in dispatch_request 2025-04-11 10:29:44.986 | return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return] 2025-04-11 10:29:44.986 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2025-04-11 10:29:44.986 | File "/app/api/.venv/lib/python3.12/site-packages/flask_restful/__init__.py", line 489, in wrapper 2025-04-11 10:29:44.986 | resp = resource(*args, **kwargs) 2025-04-11 10:29:44.986 | ^^^^^^^^^^^^^^^^^^^^^^^^^ 2025-04-11 10:29:44.986 | File "/app/api/.venv/lib/python3.12/site-packages/flask/views.py", line 110, in view 2025-04-11 10:29:44.986 | return current_app.ensure_sync(self.dispatch_request)(**kwargs) # type: ignore[no-any-return] 2025-04-11 10:29:44.986 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2025-04-11 10:29:44.986 | File "/app/api/.venv/lib/python3.12/site-packages/flask_restful/__init__.py", line 604, in dispatch_request 2025-04-11 10:29:44.986 | resp = meth(*args, **kwargs) 2025-04-11 10:29:44.986 | ^^^^^^^^^^^^^^^^^^^^^ 2025-04-11 10:29:44.986 | File "/app/api/controllers/service_api/wraps.py", line 104, in decorated_view 2025-04-11 10:29:44.986 | return view_func(*args, **kwargs) 2025-04-11 10:29:44.986 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 2025-04-11 10:29:44.986 | File "/app/api/.venv/lib/python3.12/site-packages/flask_restful/__init__.py", line 701, in wrapper 2025-04-11 10:29:44.986 | return marshal(resp, self.fields, self.envelope) 2025-04-11 10:29:44.986 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2025-04-11 10:29:44.986 | File "/app/api/.venv/lib/python3.12/site-packages/flask_restful/__init__.py", line 657, in marshal 2025-04-11 10:29:44.986 | return OrderedDict([(envelope, OrderedDict(items))]) if envelope else OrderedDict(items) 2025-04-11 10:29:44.986 | ^^^^^^^^^^^^^^^^^^ 2025-04-11 10:29:44.986 | File "/app/api/.venv/lib/python3.12/site-packages/flask_restful/__init__.py", line 655, in <genexpr> 2025-04-11 10:29:44.986 | else make(v).output(k, data)) 2025-04-11 10:29:44.986 | ^^^^^^^^^^^^^^^^^^^^^^^ 2025-04-11 10:29:44.986 | File "/app/api/.venv/lib/python3.12/site-packages/flask_restful/fields.py", line 197, in output 2025-04-11 10:29:44.986 | return self.format(value) 2025-04-11 10:29:44.986 | ^^^^^^^^^^^^^^^^^^ 2025-04-11 10:29:44.986 | File "/app/api/.venv/lib/python3.12/site-packages/flask_restful/fields.py", line 183, in format 2025-04-11 10:29:44.986 | self.container.output(idx, 2025-04-11 10:29:44.986 | File "/app/api/.venv/lib/python3.12/site-packages/flask_restful/fields.py", line 152, in output 2025-04-11 10:29:44.986 | return marshal(value, self.nested) 2025-04-11 10:29:44.986 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2025-04-11 10:29:44.986 | File "/app/api/.venv/lib/python3.12/site-packages/flask_restful/__init__.py", line 657, in marshal 2025-04-11 10:29:44.986 | return OrderedDict([(envelope, OrderedDict(items))]) if envelope else OrderedDict(items) 2025-04-11 10:29:44.986 | ^^^^^^^^^^^^^^^^^^ 2025-04-11 10:29:44.986 | File "/app/api/.venv/lib/python3.12/site-packages/flask_restful/__init__.py", line 655, in <genexpr> 2025-04-11 10:29:44.986 | else make(v).output(k, data)) 2025-04-11 10:29:44.986 | ^^^^^^^^^^^^^^ 2025-04-11 10:29:44.986 | AttributeError: 'function' object has no attribute 'output' ```
yindo added the 🐞 bug label 2026-02-21 19:09:02 -05:00
yindo closed this issue 2026-02-21 19:09:02 -05:00
Author
Owner

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

There is a known issue with the /messages API endpoint in Dify version 1.2.0 that results in a status code 500 error when trying to retrieve historical conversation content. This bug has been identified and fixed in the cloud version. As a workaround for self-hosted environments, you can use the /v1/chat-messages endpoint, which functions correctly during this period [1].

Additionally, to resolve the error in the self-hosted version, ensure you are using the latest version of the API. If the error persists, you can try the following modification in the api/controllers/service_api/app/message.py file:

Replace the line:

"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 container using the command:

docker compose restart api

This should help resolve the 500 error [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 10, 2025): <!-- Answer --> There is a known issue with the `/messages` API endpoint in Dify version 1.2.0 that results in a status code 500 error when trying to retrieve historical conversation content. This bug has been identified and fixed in the cloud version. As a workaround for self-hosted environments, you can use the `/v1/chat-messages` endpoint, which functions correctly during this period <sup>[[1]](https://github.com/langgenius/dify/issues/17829)</sup>. Additionally, to resolve the error in the self-hosted version, ensure you are using the latest version of the API. If the error persists, you can try the following modification in the `api/controllers/service_api/app/message.py` file: Replace the line: ```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 container using the command: ```bash docker compose restart api ``` This should help resolve the 500 error <sup>[[2]](https://github.com/langgenius/dify/discussions/17802)</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/8fbef6b4-5da1-4b0d-b735-99be3eb913cc?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/8fbef6b4-5da1-4b0d-b735-99be3eb913cc?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/8fbef6b4-5da1-4b0d-b735-99be3eb913cc?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/8fbef6b4-5da1-4b0d-b735-99be3eb913cc?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/8fbef6b4-5da1-4b0d-b735-99be3eb913cc?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/8fbef6b4-5da1-4b0d-b735-99be3eb913cc?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/8fbef6b4-5da1-4b0d-b735-99be3eb913cc?feedback_type=other)</sup>
Author
Owner

@MichaelNie1994 commented on GitHub (Apr 10, 2025):

same issue

@MichaelNie1994 commented on GitHub (Apr 10, 2025): same issue
Author
Owner

@maybeyourking commented on GitHub (Apr 10, 2025):

same issue

@maybeyourking commented on GitHub (Apr 10, 2025): same issue
Author
Owner

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

https://github.com/langgenius/dify/issues/17712

@crazywoola commented on GitHub (Apr 10, 2025): https://github.com/langgenius/dify/issues/17712
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#12787