The interface for obtaining session history messages reports an error #13178

Closed
opened 2026-02-21 19:10:55 -05:00 by yindo · 2 comments
Owner

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

After upgrading from 0.5.3 to 1.2.0, the interface for obtaining session history messages reports an error, as follows: curl -X GET 'http://xxx.xxx.xxx/v1/messages?conversation_id=9b94fef9-f2ff-4b9f-b918-950225ffbf73&user=18998808500' --header 'Authorization: Bearer app-a8ndbiA1qn8hFZHc3OQ5uoGv'
{"message": "Internal Server Error", "code": "unknown"}

✔️ Expected Behavior

No response

Actual Behavior

No response

Originally created by @wenhuihuang on GitHub (Apr 21, 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 After upgrading from 0.5.3 to 1.2.0, the interface for obtaining session history messages reports an error, as follows: curl -X GET 'http://xxx.xxx.xxx/v1/messages?conversation_id=9b94fef9-f2ff-4b9f-b918-950225ffbf73&user=18998808500' --header 'Authorization: Bearer app-a8ndbiA1qn8hFZHc3OQ5uoGv' {"message": "Internal Server Error", "code": "unknown"} ### ✔️ Expected Behavior _No response_ ### ❌ Actual Behavior _No response_
yindo added the 🐞 bug label 2026-02-21 19:10:55 -05:00
yindo closed this issue 2026-02-21 19:10:55 -05:00
Author
Owner

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

Hello @wenhuihuang! I'm Dosu, your friendly bot here to help you tackle bugs, answer questions, and navigate the world of contributions while we wait for a human maintainer. Let's get this sorted out together! 🛠️

There is a known issue with the /v1/messages endpoint in Dify version 1.2.0 that results in an "Internal Server Error" when trying to retrieve session history messages. This bug has been identified and fixed in the cloud version. For self-hosted environments, you can use the /v1/chat-messages endpoint as a workaround, which functions correctly during this period.

Additionally, to resolve the error in the self-hosted version, you can apply a code modification. Update the api/controllers/service_api/app/message.py file 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

This should help resolve the 500 error [1][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 21, 2025): <!-- Greeting --> Hello @wenhuihuang! I'm [Dosu](https://dosu.dev), your friendly bot here to help you tackle bugs, answer questions, and navigate the world of contributions while we wait for a human maintainer. Let's get this sorted out together! 🛠️ <!-- Answer --> There is a known issue with the `/v1/messages` endpoint in Dify version 1.2.0 that results in an "Internal Server Error" when trying to retrieve session history messages. This bug has been identified and fixed in the cloud version. For self-hosted environments, you can use the `/v1/chat-messages` endpoint as a workaround, which functions correctly during this period. Additionally, to resolve the error in the self-hosted version, you can apply a code modification. Update the `api/controllers/service_api/app/message.py` file 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 ``` This should help resolve the 500 error <sup>[[1]](https://github.com/langgenius/dify/issues/17952)</sup><sup>[[2]](https://github.com/langgenius/dify/issues/17983)</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/bc2eeb78-03c3-47a4-8ca7-9e0f8f4f888d?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/bc2eeb78-03c3-47a4-8ca7-9e0f8f4f888d?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/bc2eeb78-03c3-47a4-8ca7-9e0f8f4f888d?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/bc2eeb78-03c3-47a4-8ca7-9e0f8f4f888d?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/bc2eeb78-03c3-47a4-8ca7-9e0f8f4f888d?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/bc2eeb78-03c3-47a4-8ca7-9e0f8f4f888d?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/bc2eeb78-03c3-47a4-8ca7-9e0f8f4f888d?feedback_type=other)</sup>
Author
Owner

@xueyezs commented on GitHub (Apr 22, 2025):

I have made modifications to the source code according to the suggested changes: api/controllers/service_api/app/message.py,
May I ask if only source code deployment will take effect? Currently, we are using Docker deployment

Image
Image

@xueyezs commented on GitHub (Apr 22, 2025): I have made modifications to the source code according to the suggested changes: api/controllers/service_api/app/message.py, May I ask if only source code deployment will take effect? Currently, we are using Docker deployment ![Image](https://github.com/user-attachments/assets/85a638bf-62c6-4ae6-aa1f-75f33cfd9f6d) <img width="505" alt="Image" src="https://github.com/user-attachments/assets/75c00113-d929-4550-a64a-d6f9faecadb4" />
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#13178