Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix: 17712-get-messages-api-encountered-internal-server-error (#17716)

crazywoola63ba6077387c
diff --git a/api/controllers/service_api/app/message.py b/api/controllers/service_api/app/message.py
index 38917bf345d..95e538f4c7f 100644
--- a/api/controllers/service_api/app/message.py
+++ b/api/controllers/service_api/app/message.py
@@ -20,14 +20,6 @@ from services.message_service import MessageService
class MessageListApi(Resource):
- def get_retriever_resources(self):
- try:
- if self.message_metadata:
- return json.loads(self.message_metadata).get("retriever_resources", [])
- return []
- except (json.JSONDecodeError, TypeError):
- return []
-
message_fields = {
"id": fields.String,
"conversation_id": fields.String,
@@ -37,7 +29,11 @@ class MessageListApi(Resource):
"answer": fields.String(attribute="re_sign_file_url_answer"),
"message_files": fields.List(fields.Nested(message_file_fields)),
"feedback": fields.Nested(feedback_fields, attribute="user_feedback", allow_null=True),
- "retriever_resources": get_retriever_resources,
+ "retriever_resources": fields.Raw(
+ attribute=lambda obj: json.loads(obj.message_metadata).get("retriever_resources", [])
+ if obj.message_metadata
+ else []
+ ),
"created_at": TimestampField,
"agent_thoughts": fields.List(fields.Nested(agent_thought_fields)),
"status": fields.String,