Error when adding file to knowledge base #12418

Closed
opened 2026-02-21 19:07:19 -05:00 by yindo · 3 comments
Owner

Originally created by @xhangHU on GitHub (Mar 31, 2025).

Self Checks

  • 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 (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

1.1.1

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

When I create a knowledge base and add files he has no problem, but when I add files to a knowledge base that has already been built he reports an error 400 bad request。
api-1 | 2025-04-01 02:31:55,822 INFO [_internal.py:97] 192.168.10.24 - - [01/Apr/2025 02:31:55] "POST /console/api/datasets/b6bec8c4-3685-4fff-8f07-20ceda07908a/documents HTTP/1.1" 400 -

Image

✔️ Expected Behavior

Uploading documents to an existing knowledge base

Actual Behavior

400 Bad Requests

Originally created by @xhangHU on GitHub (Mar 31, 2025). ### Self Checks - [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 (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [x] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 1.1.1 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce When I create a knowledge base and add files he has no problem, but when I add files to a knowledge base that has already been built he reports an error 400 bad request。 `api-1 | 2025-04-01 02:31:55,822 INFO [_internal.py:97] 192.168.10.24 - - [01/Apr/2025 02:31:55] "POST /console/api/datasets/b6bec8c4-3685-4fff-8f07-20ceda07908a/documents HTTP/1.1" 400 -` ![Image](https://github.com/user-attachments/assets/5962e09b-5a26-4206-b8b2-dc0a524611b6) ### ✔️ Expected Behavior Uploading documents to an existing knowledge base ### ❌ Actual Behavior 400 Bad Requests
yindo added the 🐞 bug label 2026-02-21 19:07:19 -05:00
yindo closed this issue 2026-02-21 19:07:19 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Mar 31, 2025):

This issue is a known bug in Dify versions 1.1.1 to 1.1.3, where adding files to an existing knowledge base results in a 400 Bad Request error due to a missing weight_type field in the KnowledgeConfig model's retrieval_model.weights. To resolve this, you need to add the weight_type field with the value customized to the weights configuration in your retrieval model. The correct structure should look like this:

"weights": {
    "weight_type": "customized",
    "vector_setting": {
        "vector_weight": 0.7,
        "embedding_provider_name": "",
        "embedding_model_name": ""
    },
    "keyword_setting": {
        "keyword_weight": 0.3
    }
}

This issue has been addressed in a pull request and will be resolved in the next version release. Meanwhile, you can either wait for the update or create a new knowledge base and upload all files to it [1][2].

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

@dosubot[bot] commented on GitHub (Mar 31, 2025): <!-- Answer --> This issue is a known bug in Dify versions 1.1.1 to 1.1.3, where adding files to an existing knowledge base results in a 400 Bad Request error due to a missing `weight_type` field in the `KnowledgeConfig` model's `retrieval_model.weights`. To resolve this, you need to add the `weight_type` field with the value `customized` to the weights configuration in your retrieval model. The correct structure should look like this: ```json "weights": { "weight_type": "customized", "vector_setting": { "vector_weight": 0.7, "embedding_provider_name": "", "embedding_model_name": "" }, "keyword_setting": { "keyword_weight": 0.3 } } ``` This issue has been addressed in a pull request and will be resolved in the next version release. Meanwhile, you can either wait for the update or create a new knowledge base and upload all files to it <sup>[[1]](https://github.com/langgenius/dify/issues/16591)</sup><sup>[[2]](https://github.com/langgenius/dify/issues/16411)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.* --- <sup>Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/47c0d31b-9c5e-49f4-a57a-a7e06bbeadf2?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/47c0d31b-9c5e-49f4-a57a-a7e06bbeadf2?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/47c0d31b-9c5e-49f4-a57a-a7e06bbeadf2?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/47c0d31b-9c5e-49f4-a57a-a7e06bbeadf2?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/47c0d31b-9c5e-49f4-a57a-a7e06bbeadf2?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/47c0d31b-9c5e-49f4-a57a-a7e06bbeadf2?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/47c0d31b-9c5e-49f4-a57a-a7e06bbeadf2?feedback_type=other)</sup>
Author
Owner

@xhangHU commented on GitHub (Mar 31, 2025):

@dosu I solved the problem. By adding in
api\services\entities\knowledge_entities\knowledge_entities.py
Change the code in line 98.
weight_type: str = “customised”
The reason for this is that there is no default value. Hope this helps someone who is experiencing the same problem.

@xhangHU commented on GitHub (Mar 31, 2025): @dosu I solved the problem. By adding in `api\services\entities\knowledge_entities\knowledge_entities.py ` Change the code in line 98. `weight_type: str = “customised”` The reason for this is that there is no default value. Hope this helps someone who is experiencing the same problem.
Author
Owner

@dosubot[bot] commented on GitHub (Mar 31, 2025):

@xhangHU That's awesome that you found a solution! 🎉 However, I'm just a bot here to help with bugs, technical questions, and engineering knowledge. If you think I should have more to say on this, feel free to reach out to the Dosu Team. Keep up the great work!

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

@dosubot[bot] commented on GitHub (Mar 31, 2025): <!-- Answer --> @xhangHU That's awesome that you found a solution! 🎉 However, I'm just a bot here to help with bugs, technical questions, and engineering knowledge. If you think I should have more to say on this, feel free to reach out to the [Dosu Team](mailto:customersuccess@dosu.dev). Keep up the great work! <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.* --- <sup>Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/298f53af-fad4-4ef5-a555-08446405da6c?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/298f53af-fad4-4ef5-a555-08446405da6c?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/298f53af-fad4-4ef5-a555-08446405da6c?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/298f53af-fad4-4ef5-a555-08446405da6c?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/298f53af-fad4-4ef5-a555-08446405da6c?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/298f53af-fad4-4ef5-a555-08446405da6c?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/298f53af-fad4-4ef5-a555-08446405da6c?feedback_type=other)</sup>
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#12418