I updated the latest code in version 1.2.0, but still encountered an error when requesting the/v1/messages endpoint #12788

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

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

error
Image
code
Image

✔️ Expected Behavior

Being able to correctly retrieve the content of the message

Actual Behavior

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

Originally created by @fdj-123 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 error ![Image](https://github.com/user-attachments/assets/8518016e-6454-43f7-bf49-6be22b328f66) code ![Image](https://github.com/user-attachments/assets/e1a7d0a5-f49e-4e6b-b5be-cba1ea373293) ### ✔️ Expected Behavior Being able to correctly retrieve the content of the message ### ❌ Actual Behavior { "message": "Internal Server Error", "code": "unknown" }
yindo closed this issue 2026-02-21 19:09:03 -05:00
Author
Owner

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

There are similar issues reported with the /v1/messages endpoint in Dify version 1.2.0, particularly when using a self-hosted Docker setup. The error you're encountering is a known issue, and a solution has been identified.

To resolve the 500 Internal Server Error, you can try the following steps:

  1. Locate the file api/controllers/service_api/app/message.py in your Docker setup.

  2. 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=[]),
    
  3. Restart the API container using the command:

    docker compose restart api
    

This fix addresses the issue by correcting the way retriever_resources is handled in the schema, which 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 10, 2025): <!-- Answer --> There are similar issues reported with the `/v1/messages` endpoint in Dify version 1.2.0, particularly when using a self-hosted Docker setup. The error you're encountering is a known issue, and a solution has been identified. To resolve the 500 Internal Server Error, you can try the following steps: 1. Locate the file `api/controllers/service_api/app/message.py` in your Docker setup. 2. 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=[]), ``` 3. Restart the API container using the command: ```bash docker compose restart api ``` This fix addresses the issue by correcting the way `retriever_resources` is handled in the schema, which should help resolve the 500 error <sup>[[1]](https://github.com/langgenius/dify/issues/17839)</sup><sup>[[2]](https://github.com/langgenius/dify/issues/17817)</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/521c3db4-ea78-46fb-ab93-b2adf2ef8668?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/521c3db4-ea78-46fb-ab93-b2adf2ef8668?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/521c3db4-ea78-46fb-ab93-b2adf2ef8668?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/521c3db4-ea78-46fb-ab93-b2adf2ef8668?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/521c3db4-ea78-46fb-ab93-b2adf2ef8668?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/521c3db4-ea78-46fb-ab93-b2adf2ef8668?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/521c3db4-ea78-46fb-ab93-b2adf2ef8668?feedback_type=other)</sup>
Author
Owner

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

I updated the code for the latest branch, but it still hasn't solved the problem

@maybeyourking commented on GitHub (Apr 11, 2025): I updated the code for the latest branch, but it still hasn't solved the problem
Author
Owner

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

Has this problem been solved? @maybeyourking

@MichaelNie1994 commented on GitHub (Apr 11, 2025): Has this problem been solved? @maybeyourking
Author
Owner

@HMT970958361 commented on GitHub (Apr 16, 2025):

Replace "retriever_resources": get_retriever_resources, with "retriever_resources": fields.Raw(attribute=lambda obj: json.loads(obj.message_metadata).get("retriever_resources", []) if obj.message_metadata else []), is ok!

@HMT970958361 commented on GitHub (Apr 16, 2025): Replace `"retriever_resources": get_retriever_resources,` with `"retriever_resources": fields.Raw(attribute=lambda obj: json.loads(obj.message_metadata).get("retriever_resources", []) if obj.message_metadata else []),` is ok!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#12788