Bug: Web app /messages returns `retriever_resources Input should be a valid list` when a message has no retriever_resources

Open Beginner friendly
#41,688 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
86/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
api, backend

Research direction

Start in api/models/model.py at the retriever_resources property, then inspect api/fields/message_fields.py and controllers/web/message.py to trace the GET /messages response. Ensure messages without a retriever_resources key produce an empty list rather than None, and verify the embedded web history loads for a flow without a Knowledge Retrieval node.

Written by the indexing model from the issue text.

Description

🐞 bug 1.17.0
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

1.17.0

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce
  1. Create a Chatflow / Agent app that does not use a Knowledge Retrieval node. For example, a flow with an SQL query node (or HTTP request node, or Agent node with tool calling).
  2. Publish the app and embed it into an external page using the "Embed" snippet (the web app, not the service API).
  3. Send a message so that the conversation history contains at least one message without any retriever_resources.
  4. Reload the embedded page so it loads the message history via GET /messages.
✔️ Expected Behavior

Message history loads normally, with retriever_resources as an empty list ([]) for messages that had no retrieval.

❌ Actual Behavior

The embedded page throws:

1 validation error for WebMessageListItem
retriever_resources
  Input should be a valid list
  [type=list_type, input_value=None, input_type=NoneType]

And the history fails to render.

Root cause

api/models/model.py (around line 1823):

@property
def retriever_resources(self) -> Any:
    return self.message_metadata_dict.get("retriever_resources") if self.message_metadata else []

When message_metadata exists but does not contain the retriever_resources key, .get("retriever_resources") returns None instead of []. This None then reaches the required field WebMessageListItem.retriever_resources: list[RetrieverResource] in api/fields/message_fields.py and fails Pydantic validation.

Note: the service_api path (controllers/service_api/app/message.py) was already fixed in PR #17304 (issue #14650), but the web path (controllers/web/message.pyWebMessageListItem) still uses the un-guarded property above.

Suggested fix

Give the .get() a default value so a missing key resolves to an empty list:

return self.message_metadata_dict.get("retriever_resources", []) if self.message_metadata else []

I have verified this one-line change fixes the issue on a self-hosted 1.17.0 Docker deployment.

Dominant language
TypeScript
Stars
157k
Forks
24.7k
Avg merge
22h 32m
Merged PRs (30d)
611

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from langgenius/dify

All issues in langgenius/dify

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.