langgenius / langgenius/dify

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
🐞 bug 1.17.0
Dominant language
TypeScript
Stars
156k
Forks
24.6k
Avg merge
22h 9m
Merged PRs (30d)
610

Description

### 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

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):

```python
@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.py` → `WebMessageListItem`) still uses the un-guarded property above.

### Suggested fix

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

```python
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.

Contributor guide

Open the contributing guide

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.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.