AttributeError in MessageListApi due to incorrect retriever_resources field definition #16285

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

Originally created by @mengshiliu0830 on GitHub (Aug 20, 2025).

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • 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, otherwise it will be closed.
  • 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

Dify Version: 1.2.0

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

Description

The retriever_resources field in MessageListApi.message_fields is incorrectly defined as a function call instead of a proper Flask-RESTful field definition, causing an AttributeError when the API endpoint is accessed.

Error Details

AttributeError: 'function' object has no attribute 'format'

Location

File: api/controllers/service_api/app/message.py Line: ~30 (in MessageListApi.message_fields dictionary)

Root Cause

The field is currently defined as:
"retriever_resources": get_retriever_resources,
But should be:
"retriever_resources": fields.List(fields.Nested(retriever_resource_fields)),

Impact

  • API endpoint /messages returns 500 Internal Server Error
  • Service API functionality is broken for message retrieval
  • Affects chat applications and agent chat modes

Steps to Reproduce

  1. Start the Dify application
  2. Make a request to the /messages endpoint via Service API
  3. Observe the AttributeError in the logs

Expected Behavior

The API should return a properly formatted response with retriever_resources as a list of nested objects.

Proposed Fix

Replace the function call with the correct field definition:

In MessageListApi.message_fields dictionary

"retriever_resources": fields.List(fields.Nested(retriever_resource_fields)),

Environment

  • Dify Version: 1.2.0
  • Deployment: Docker Compose
  • Python Version: 3.x

Additional Notes

  • This appears to be a regression or oversight in the field definition
  • The retriever_resource_fields is properly imported and available
  • Similar patterns are used correctly for other nested fields in the same class

✔️ Expected Behavior

The API should return a properly formatted response with retriever_resources as a list of nested objects.

Actual Behavior

No response

Originally created by @mengshiliu0830 on GitHub (Aug 20, 2025). ### Self Checks - [x] I have read the [Contributing Guide](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) and [Language Policy](https://github.com/langgenius/dify/issues/1542). - [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, otherwise it will be closed. - [x] 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version Dify Version: 1.2.0 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce ### Description The retriever_resources field in MessageListApi.message_fields is incorrectly defined as a function call instead of a proper Flask-RESTful field definition, causing an AttributeError when the API endpoint is accessed. ### Error Details AttributeError: 'function' object has no attribute 'format' ### Location File: api/controllers/service_api/app/message.py Line: ~30 (in MessageListApi.message_fields dictionary) ### Root Cause The field is currently defined as: "retriever_resources": get_retriever_resources, But should be: "retriever_resources": fields.List(fields.Nested(retriever_resource_fields)), ### Impact - API endpoint /messages returns 500 Internal Server Error - Service API functionality is broken for message retrieval - Affects chat applications and agent chat modes ### Steps to Reproduce 1. Start the Dify application 2. Make a request to the /messages endpoint via Service API 3. Observe the AttributeError in the logs ### Expected Behavior The API should return a properly formatted response with retriever_resources as a list of nested objects. ### Proposed Fix Replace the function call with the correct field definition: ### In MessageListApi.message_fields dictionary "retriever_resources": fields.List(fields.Nested(retriever_resource_fields)), ### Environment - Dify Version: 1.2.0 - Deployment: Docker Compose - Python Version: 3.x ### Additional Notes - This appears to be a regression or oversight in the field definition - The retriever_resource_fields is properly imported and available - Similar patterns are used correctly for other nested fields in the same class ### ✔️ Expected Behavior The API should return a properly formatted response with retriever_resources as a list of nested objects. ### ❌ Actual Behavior _No response_
yindo added the 🐞 bugwont-fix labels 2026-02-21 19:25:27 -05:00
yindo closed this issue 2026-02-21 19:25:27 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Aug 20, 2025):

Hi @mengshiliu0830! I'm Dosu and I’m helping the dify team.

The AttributeError in Dify v1.2.0's /messages API endpoint is caused by the retriever_resources field in MessageListApi being defined as a function or improper field, which breaks Flask-RESTful's serialization. To fix this, update the field definition in api/controllers/service_api/app/message.py to:

"retriever_resources": fields.List(fields.Nested(retriever_resource_fields)),

or, if you expect a list of strings:

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

After making the change, restart your API container for the fix to take effect. This issue is resolved in Dify v1.3.0, so upgrading is a permanent solution. As a workaround, you can use the /v1/chat-messages endpoint instead of /v1/messages. If you're running Python 3.12, consider downgrading to Python 3.11, as some reports indicate compatibility issues with 3.12 in v1.2.0 [source 1] [source 2] [source 3].

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

@dosubot[bot] commented on GitHub (Aug 20, 2025): <!-- Greeting --> Hi @mengshiliu0830! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the dify team. <!-- Answer --> The AttributeError in Dify v1.2.0's /messages API endpoint is caused by the retriever_resources field in MessageListApi being defined as a function or improper field, which breaks Flask-RESTful's serialization. To fix this, update the field definition in api/controllers/service_api/app/message.py to: ```python "retriever_resources": fields.List(fields.Nested(retriever_resource_fields)), ``` or, if you expect a list of strings: ```python "retriever_resources": fields.List(fields.String, attribute=lambda x: json.loads(x.message_metadata).get('retriever_resources', []), default=[]), ``` After making the change, restart your API container for the fix to take effect. This issue is resolved in Dify v1.3.0, so upgrading is a permanent solution. As a workaround, you can use the /v1/chat-messages endpoint instead of /v1/messages. If you're running Python 3.12, consider downgrading to Python 3.11, as some reports indicate compatibility issues with 3.12 in v1.2.0 [[source 1]](https://github.com/langgenius/dify/issues/21003) [[source 2]](https://github.com/langgenius/dify/issues/17983) [[source 3]](https://github.com/langgenius/dify/issues/18776). <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/eed42259-e00c-4044-b11a-96e8a126e233?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/eed42259-e00c-4044-b11a-96e8a126e233?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/eed42259-e00c-4044-b11a-96e8a126e233?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/eed42259-e00c-4044-b11a-96e8a126e233?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/eed42259-e00c-4044-b11a-96e8a126e233?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/eed42259-e00c-4044-b11a-96e8a126e233?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/eed42259-e00c-4044-b11a-96e8a126e233?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/6088a4f4-073a-43f3-b3d4-4f06fb0c05a0/ask?utm_source=github)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify/issues/24202)
Author
Owner

@crazywoola commented on GitHub (Aug 20, 2025):

This is outdated version, I think there are lots of fixes related to this issue already.

@crazywoola commented on GitHub (Aug 20, 2025): This is outdated version, I think there are lots of fixes related to this issue already.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#16285