Image url will not completed if a document start with an image #7258

Closed
opened 2026-02-21 18:19:41 -05:00 by yindo · 4 comments
Owner

Originally created by @Qiuzg on GitHub (Dec 18, 2024).

Originally assigned to: @JohnJyong on GitHub.

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

0.14.0

Cloud or Self Hosted

Self Hosted (Source)

Steps to reproduce

If a document start with an image, this image will convert to a url, the function transform() in /api/core/rag/index_processor/processor/paragraph_index_precessor.py will call the remove_leading_symbols(), and the symbol ![ will be cleaned by this fucntion

![image](http://xxxx) ---> image](http://XXXX)

✔️ Expected Behavior

No response

Actual Behavior

No response

Originally created by @Qiuzg on GitHub (Dec 18, 2024). Originally assigned to: @JohnJyong on GitHub. ### 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 0.14.0 ### Cloud or Self Hosted Self Hosted (Source) ### Steps to reproduce If a document start with an image, this image will convert to a url, the function `transform()` in `/api/core/rag/index_processor/processor/paragraph_index_precessor.py `will call the `remove_leading_symbols()`, and the symbol `![` will be cleaned by this fucntion `![image](http://xxxx)` ---> `image](http://XXXX)` ### ✔️ Expected Behavior _No response_ ### ❌ Actual Behavior _No response_
yindo added the 🐞 bug label 2026-02-21 18:19:41 -05:00
yindo closed this issue 2026-02-21 18:19:41 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Dec 18, 2024):

The issue you're encountering seems to be related to the remove_leading_symbols() function, which is removing the leading ![ from image URLs when a document starts with an image. This results in the image URL being incomplete, as the markdown syntax for images (![alt text](URL)) is disrupted.

To address this, you might consider modifying the remove_leading_symbols() function to exclude the ![ pattern from being removed when processing image URLs. This would ensure that the markdown syntax for images remains intact, allowing the URLs to be correctly formatted and rendered.

If you need further assistance with implementing this change, feel free to ask!

To continue talking to Dosu, mention @dosu.


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

@dosubot[bot] commented on GitHub (Dec 18, 2024): <!-- Answer --> The issue you're encountering seems to be related to the `remove_leading_symbols()` function, which is removing the leading `![` from image URLs when a document starts with an image. This results in the image URL being incomplete, as the markdown syntax for images (`![alt text](URL)`) is disrupted. To address this, you might consider modifying the `remove_leading_symbols()` function to exclude the `![` pattern from being removed when processing image URLs. This would ensure that the markdown syntax for images remains intact, allowing the URLs to be correctly formatted and rendered. If you need further assistance with implementing this change, feel free to ask! <!-- 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/9f2e08f6-43a7-4b39-8384-10224f030012?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/9f2e08f6-43a7-4b39-8384-10224f030012?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/9f2e08f6-43a7-4b39-8384-10224f030012?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/9f2e08f6-43a7-4b39-8384-10224f030012?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/9f2e08f6-43a7-4b39-8384-10224f030012?feedback_type=hallucination) | [Other](https://app.dosu.dev/response-feedback/9f2e08f6-43a7-4b39-8384-10224f030012?feedback_type=other)</sup>
Author
Owner

@FAN20011217 commented on GitHub (Dec 18, 2024):

I encountered the same problem

@FAN20011217 commented on GitHub (Dec 18, 2024): I encountered the same problem
Author
Owner

@shengxiagit commented on GitHub (Dec 20, 2024):

The problem was solved after trying to modify the regular expression to:

pattern = r"^(?!!\[image\])([!\u2000-\u206F\u2E00-\u2E7F\u3000-\u303F\"#$%&'()*+,\-./:;<=>?@\[\]^_`{|}~]+)"
@shengxiagit commented on GitHub (Dec 20, 2024): The problem was solved after trying to modify the regular expression to: ``` python dify/api/core/tools/utils/text_processing_utils.py pattern = r"^(?!!\[image\])([!\u2000-\u206F\u2E00-\u2E7F\u3000-\u303F\"#$%&'()*+,\-./:;<=>?@\[\]^_`{|}~]+)" ```
Author
Owner

@dosubot[bot] commented on GitHub (Jan 22, 2025):

Hi, @Qiuzg. I'm Dosu, and I'm helping the Dify team manage their backlog and am marking this issue as stale.

Issue Summary:

  • A bug was reported in Dify version 0.14.0 where remove_leading_symbols() removed ![ from image markdown, causing incomplete URLs.
  • I suggested preserving the ![ pattern for image URLs.
  • User FAN20011217 confirmed the issue.
  • Shengxiagit resolved it by adjusting the regular expression to preserve the ![ pattern.

Next Steps:

  • Please confirm if this issue is still relevant to the latest version of Dify. If so, you can keep the discussion open by commenting.
  • If no further activity occurs, this issue will be automatically closed in 15 days.

Thank you for your understanding and contribution!

@dosubot[bot] commented on GitHub (Jan 22, 2025): Hi, @Qiuzg. I'm [Dosu](https://dosu.dev), and I'm helping the Dify team manage their backlog and am marking this issue as stale. **Issue Summary:** - A bug was reported in Dify version 0.14.0 where `remove_leading_symbols()` removed `![` from image markdown, causing incomplete URLs. - I suggested preserving the `![` pattern for image URLs. - User FAN20011217 confirmed the issue. - Shengxiagit resolved it by adjusting the regular expression to preserve the `![` pattern. **Next Steps:** - Please confirm if this issue is still relevant to the latest version of Dify. If so, you can keep the discussion open by commenting. - If no further activity occurs, this issue will be automatically closed in 15 days. Thank you for your understanding and contribution!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#7258