Jina rerank fails #684

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

Originally created by @DavideDelbianco on GitHub (Oct 1, 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.9.1

Plugin version

0.0.8

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

Jina AI has changed the default value of the request parameter "return_documents": false
this means that the body of the document is no longer returned and the rerank call is probably failing for that rason:

Image Image

✔️ Error log

[jina] Error: req_id: 6ff416ac64 PluginInvokeError: {"args":{"description":"[models] Error: string indices must be integers, not 'str'"},"error_type":"InvokeError","message":"[models] Error: string indices must be integers, not 'str'"}

Originally created by @DavideDelbianco on GitHub (Oct 1, 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.9.1 ### Plugin version 0.0.8 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce Jina AI has changed the default value of the request parameter "return_documents": false this means that the body of the document is no longer returned and the rerank call is probably failing for that rason: <img width="1021" height="591" alt="Image" src="https://github.com/user-attachments/assets/f253589d-39b4-42ea-9465-194d4b7866fb" /> <img width="1828" height="1044" alt="Image" src="https://github.com/user-attachments/assets/d12583c5-f233-4794-8b1c-5af0db1db6c2" /> ### ✔️ Error log [jina] Error: req_id: 6ff416ac64 PluginInvokeError: {"args":{"description":"[models] Error: string indices must be integers, not 'str'"},"error_type":"InvokeError","message":"[models] Error: string indices must be integers, not 'str'"}
yindo added the bug label 2026-02-16 10:20:11 -05:00
yindo closed this issue 2026-02-16 10:20:11 -05:00
Author
Owner

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

The Jina rerank failure is caused by the recent change in Jina's API: when "return_documents": false, the response no longer includes document bodies, but the Dify plugin code still tries to access result["document"]["text"]. This leads to the error string indices must be integers, not 'str' because the expected dictionary is missing and the code attempts to index a string or a null value instead.

To fix this, update the rerank plugin code to check if result["document"] exists and is a dictionary before accessing its "text" field. If the document body is missing, you can either skip that result or provide a default value (like an empty string). For example:

if isinstance(result.get("document"), dict) and "text" in result["document"]:
    page_content = result["document"]["text"]
elif isinstance(result.get("document"), str):
    page_content = result["document"]
else:
    page_content = ""  # or handle as needed

This change will prevent the plugin from crashing when document bodies are missing and allow it to handle the new Jina API response gracefully. There is no built-in config to handle this in Dify, so a code patch is needed for robust integration with Jina's rerank endpoint [source].

Recent error handling improvements in other plugins show a trend toward more robust error categorization, but do not directly address this Jina rerank issue [source]. For now, patching the plugin code as above is the recommended workaround.

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 1, 2025): <!-- Answer --> The Jina rerank failure is caused by the recent change in Jina's API: when `"return_documents": false`, the response no longer includes document bodies, but the Dify plugin code still tries to access `result["document"]["text"]`. This leads to the error `string indices must be integers, not 'str'` because the expected dictionary is missing and the code attempts to index a string or a null value instead. To fix this, update the rerank plugin code to check if `result["document"]` exists and is a dictionary before accessing its `"text"` field. If the document body is missing, you can either skip that result or provide a default value (like an empty string). For example: ```python if isinstance(result.get("document"), dict) and "text" in result["document"]: page_content = result["document"]["text"] elif isinstance(result.get("document"), str): page_content = result["document"] else: page_content = "" # or handle as needed ``` This change will prevent the plugin from crashing when document bodies are missing and allow it to handle the new Jina API response gracefully. There is no built-in config to handle this in Dify, so a code patch is needed for robust integration with Jina's rerank endpoint [[source]](https://github.com/langgenius/dify-official-plugins/pull/1659). Recent error handling improvements in other plugins show a trend toward more robust error categorization, but do not directly address this Jina rerank issue [[source]](https://github.com/langgenius/dify-official-plugins/pull/1636). For now, patching the plugin code as above is the recommended workaround. <!-- 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/5596cb8f-cb69-430f-aa03-b9ac50764dfa?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/5596cb8f-cb69-430f-aa03-b9ac50764dfa?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/5596cb8f-cb69-430f-aa03-b9ac50764dfa?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/5596cb8f-cb69-430f-aa03-b9ac50764dfa?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/5596cb8f-cb69-430f-aa03-b9ac50764dfa?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/5596cb8f-cb69-430f-aa03-b9ac50764dfa?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/5596cb8f-cb69-430f-aa03-b9ac50764dfa?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/1799)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify-official-plugins#684