langgenius / langgenius/dify

[Cloud] Knowledge Retrieval returns empty results in Workflow and Dataset API key endpoint returns 500

Open
#42,087 3 comments 2 reactions 0 assignees View on GitHub
🐞 bug
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

Cloud

### Steps to reproduce

1. Create a Knowledge Base in Dify Cloud.
2. Use "gemini-embedding-001" as the embedding model.
3. Upload documents and wait until they are available.
4. Open Retrieval Testing in the Knowledge Base.
5. Search for a term contained in the documents (for example, "はま寿司").
6. Confirm that Retrieval Testing successfully returns matching chunks.
7. Create a Workflow and add a Knowledge Retrieval node using the same Knowledge Base.
8. Set the Workflow input variable as the query for the Knowledge Retrieval node.
9. Run the Workflow with exactly the same query ("はま寿司").
10. The Knowledge Retrieval node completes successfully, but returns:

{"result":[]}

11. I also tried:
- Hybrid Search with reranking
- Weighted Score (Semantic 0.7 / Keyword 0.3)
- Top K = 10
- Score Threshold = OFF
- Creating a completely new Knowledge Retrieval node

The result is still empty.

Additionally, I enabled the Knowledge Service API, but no API key creation/management UI is displayed under API Access.

While logged in as the Workspace Owner, I tested:

GET /console/api/datasets/{dataset_id}/api-keys

Without X-Csrf-Token, it returns 401 as expected:
"CSRF token is missing or invalid."

With the valid X-Csrf-Token from the Dify Console session, the endpoint returns:

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

### ✔️ Expected Behavior

The Knowledge Retrieval node in a Workflow should return the same relevant Knowledge chunks that are successfully returned by Retrieval Testing for the same Knowledge Base and query.

Also, when the Knowledge Service API is enabled, the Workspace Owner should be able to create or manage a Dataset/Knowledge API key so that the Knowledge retrieval API can be used.

### ❌ Actual Behavior

Retrieval Testing works correctly and returns relevant chunks, but the Knowledge Retrieval node in the Workflow always returns:

{"result":[]}

The node reports success, but no records are returned.

In addition, the Knowledge API Access area does not provide any API key creation/management UI, even for the Workspace Owner.

The internal dataset API-key GET endpoint returns HTTP 500 after valid CSRF authentication.

Image

Contributor guide

Open the contributing guide

Research direction

Start with the Workflow Knowledge Retrieval node and compare its behavior with Knowledge Base Retrieval Testing using the same query and embedding model. Then inspect GET /console/api/datasets/{dataset_id}/api-keys with and without the valid X-Csrf-Token. Done means matching chunks are returned in the workflow and Workspace Owners can manage API keys without a 500 response.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
ai, api, backend, cloud, search
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.