Failed to add rerank model by openai-api-compatible plugin, return "400 Error" #747

Closed
opened 2026-02-16 10:20:22 -05:00 by yindo · 1 comment
Owner

Originally created by @plutonji on GitHub (Oct 23, 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 Dify issues & Dify Official Plugins, 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.8.1

Plugin version

0.0.22

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

  1. Install OpenAI-API-Compatible
  2. Add a model by selecting Rerank type

It failed with a "400 client error"

Image

✔️ Error log

We get the network package sent to validate the server.

Image

It shows top_n = 3 while there were only two documents so the server failed.

Check the code here:

https://github.com/langgenius/dify-official-plugins/blob/main/models/openai_api_compatible/models/rerank/rerank.py

We can see there are only two strings from line 24 to 27 because there is no comma at line 24 and 26!

Originally created by @plutonji on GitHub (Oct 23, 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 [Dify issues](https://github.com/langgenius/dify/issues) & [Dify Official Plugins](https://github.com/langgenius/dify-official-plugins/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.8.1 ### Plugin version 0.0.22 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce 1. Install OpenAI-API-Compatible 2. Add a model by selecting Rerank type It failed with a "400 client error" <img width="1636" height="1134" alt="Image" src="https://github.com/user-attachments/assets/8b048bdd-8cc4-4b00-936d-62f279f5a2b0" /> ### ✔️ Error log We get the network package sent to validate the server. <img width="802" height="1066" alt="Image" src="https://github.com/user-attachments/assets/7186e49d-f5d0-4ac5-b3d8-86373b0287a2" /> It shows top_n = 3 while there were only two documents so the server failed. Check the code here: https://github.com/langgenius/dify-official-plugins/blob/main/models/openai_api_compatible/models/rerank/rerank.py We can see there are only two strings from line 24 to 27 because there is no comma at line 24 and 26!
yindo added the bug label 2026-02-16 10:20:22 -05:00
yindo closed this issue 2026-02-16 10:20:22 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Oct 23, 2025):

Hi @plutonji! I'm Dosu and I’m helping the dify-official-plugins team.

The 400 error happens because in rerank.py, the docs list is missing commas between string entries, so Python treats them as a single string instead of two separate documents. This leads to a mismatch: top_n is set to 3, but only one (concatenated) document is sent, causing the server to reject the request since top_n must not exceed the number of documents.

To fix this, add commas between the document strings in the docs list so each document is a separate list item. This will ensure the payload matches the expected format and prevent the 400 error. You can see the relevant code and explanation here.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Join Discord Share on X

@dosubot[bot] commented on GitHub (Oct 23, 2025): <!-- Greeting --> Hi @plutonji! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the dify-official-plugins team. <!-- Answer --> The 400 error happens because in rerank.py, the docs list is missing commas between string entries, so Python treats them as a single string instead of two separate documents. This leads to a mismatch: top_n is set to 3, but only one (concatenated) document is sent, causing the server to reject the request since top_n must not exceed the number of documents. To fix this, add commas between the document strings in the docs list so each document is a separate list item. This will ensure the payload matches the expected format and prevent the 400 error. You can see the relevant code and explanation [here](https://github.com/langgenius/dify-official-plugins/blob/f32226e4db3adebff21082f770ac5bb833551484/models/openai_api_compatible/models/rerank/rerank.py). <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/9aa49d55-922a-459f-8fa5-62b949c2f16d?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/9aa49d55-922a-459f-8fa5-62b949c2f16d?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/9aa49d55-922a-459f-8fa5-62b949c2f16d?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/9aa49d55-922a-459f-8fa5-62b949c2f16d?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/9aa49d55-922a-459f-8fa5-62b949c2f16d?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/9aa49d55-922a-459f-8fa5-62b949c2f16d?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/9aa49d55-922a-459f-8fa5-62b949c2f16d?feedback_type=other)</sup>&nbsp;&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify-official-plugins/issues/1916)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify-official-plugins#747