publish to run app, the image shows error when using markdown url. #4147

Closed
opened 2026-02-21 18:04:58 -05:00 by yindo · 3 comments
Owner

Originally created by @guobaozu on GitHub (Jun 18, 2024).

Originally assigned to: @iamjoel 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).
  • Please do not modify this template :) and fill in all the required fields.

Dify version

0.6.10

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

build ai agent, public run app.
get the image url markdown format as follows:
{"text_to_texture": "{"url": ""}"}

but dify will show cut the url to beijing.aliyuncs.com/7d/fe/20240618/65a8eb47/20240618_125615_seed-47593_000_17bb2fba-2d2f-11ef-bca9-00163e0a1f6e.jpg

and then shows error.

iShot_2024-06-18_14 15 30

✔️ Expected Behavior

markdown url format shows OK.

Actual Behavior

image shows error, because dify cuts url before the seperator charactor '?'
such as the original url is :https://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/7d/fe/20240618/65a8eb47/20240618_125615_seed-47593_000_17bb2fba-2d2f-11ef-bca9-00163e0a1f6e.jpg?Expires=1718772975&OSSAccessKeyId=LTAI5tQZd8AEcZX6KZV4G8qL&Signature=8GVAHzDiboYAnBhArCJ01GorkMg%3D

the image url finally will be :https://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/7d/fe/20240618/65a8eb47/20240618_125615_seed-47593_000_17bb2fba-2d2f-11ef-bca9-00163e0a1f6e.jpg

Originally created by @guobaozu on GitHub (Jun 18, 2024). Originally assigned to: @iamjoel 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] Please do not modify this template :) and fill in all the required fields. ### Dify version 0.6.10 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce build ai agent, public run app. get the image url markdown format as follows: {"text_to_texture": "{\"url\": \"![](https://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/7d/fe/20240618/65a8eb47/20240618_125615_seed-47593_000_17bb2fba-2d2f-11ef-bca9-00163e0a1f6e.jpg?Expires=1718772975&OSSAccessKeyId=LTAI5tQZd8AEcZX6KZV4G8qL&Signature=8GVAHzDiboYAnBhArCJ01GorkMg%3D)\"}"} but dify will show cut the url to beijing.aliyuncs.com/7d/fe/20240618/65a8eb47/20240618_125615_seed-47593_000_17bb2fba-2d2f-11ef-bca9-00163e0a1f6e.jpg and then shows error. <img width="809" alt="iShot_2024-06-18_14 15 30" src="https://github.com/langgenius/dify/assets/97087217/050e0232-e30b-4e85-b209-00449d8811fb"> ### ✔️ Expected Behavior markdown url format shows OK. ### ❌ Actual Behavior image shows error, because dify cuts url before the seperator charactor '?' such as the original url is :https://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/7d/fe/20240618/65a8eb47/20240618_125615_seed-47593_000_17bb2fba-2d2f-11ef-bca9-00163e0a1f6e.jpg?Expires=1718772975&OSSAccessKeyId=LTAI5tQZd8AEcZX6KZV4G8qL&Signature=8GVAHzDiboYAnBhArCJ01GorkMg%3D the image url finally will be :https://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/7d/fe/20240618/65a8eb47/20240618_125615_seed-47593_000_17bb2fba-2d2f-11ef-bca9-00163e0a1f6e.jpg
yindo added the 🐞 bug label 2026-02-21 18:04:58 -05:00
yindo closed this issue 2026-02-21 18:04:58 -05:00
Author
Owner

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

@guobaozu Hello there! I'm here to assist you with bug fixes, questions, and contributions. Let me know how I can help while we wait for a human maintainer.

The issue you're encountering with URL truncation in markdown format is likely related to how the Markdown component processes URLs. The Markdown component in Dify uses the ReactMarkdown library with several plugins, including RemarkGfm, which should handle URLs correctly. However, it seems that URLs containing query parameters are being truncated.

To address this, you might want to check the Markdown component implementation in web/app/components/base/markdown.tsx to ensure that URLs with query parameters are handled correctly. Here is the relevant part of the Markdown component:

<ReactMarkdown
  remarkPlugins={[[RemarkMath, { singleDollarTextMath: false }], RemarkGfm, RemarkBreaks]}
  rehypePlugins={[
    RehypeKatex as any,
  ]}
  components={{
    // other components
  }}
  linkTarget='_blank'
>
  {latexContent}
</ReactMarkdown>

If the issue persists, you might need to look into the specific handling of URLs within the ReactMarkdown and RemarkGfm plugins to ensure they are not inadvertently truncating URLs with query parameters.

Additionally, there are environment-specific settings in the Docker setup for Dify that could affect URL handling. Ensure that the relevant environment variables such as CONSOLE_API_URL, APP_API_URL, CONSOLE_WEB_URL, SERVICE_API_URL, and APP_WEB_URL are correctly configured in your docker-compose.yaml file and .env files [1][2][3].

If you need further assistance, you might want to review the tests related to URL handling in api/tests/unit_tests/libs/test_yarl.py to ensure that URL concatenation and handling are working as expected [4].

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Jun 18, 2024): <!-- Greeting --> @guobaozu Hello there! I'm here to assist you with bug fixes, questions, and contributions. Let me know how I can help while we wait for a human maintainer. <!-- Answer --> The issue you're encountering with URL truncation in markdown format is likely related to how the `Markdown` component processes URLs. The `Markdown` component in Dify uses the `ReactMarkdown` library with several plugins, including `RemarkGfm`, which should handle URLs correctly. However, it seems that URLs containing query parameters are being truncated. To address this, you might want to check the `Markdown` component implementation in `web/app/components/base/markdown.tsx` to ensure that URLs with query parameters are handled correctly. Here is the relevant part of the `Markdown` component: ```tsx <ReactMarkdown remarkPlugins={[[RemarkMath, { singleDollarTextMath: false }], RemarkGfm, RemarkBreaks]} rehypePlugins={[ RehypeKatex as any, ]} components={{ // other components }} linkTarget='_blank' > {latexContent} </ReactMarkdown> ``` If the issue persists, you might need to look into the specific handling of URLs within the `ReactMarkdown` and `RemarkGfm` plugins to ensure they are not inadvertently truncating URLs with query parameters. Additionally, there are environment-specific settings in the Docker setup for Dify that could affect URL handling. Ensure that the relevant environment variables such as `CONSOLE_API_URL`, `APP_API_URL`, `CONSOLE_WEB_URL`, `SERVICE_API_URL`, and `APP_WEB_URL` are correctly configured in your `docker-compose.yaml` file and `.env` files <sup>[[1]](https://github.com/langgenius/dify/blob/main/docker/docker-compose.yaml)</sup><sup>[[2]](https://github.com/langgenius/dify-docs/blob/main/en/getting-started/install-self-hosted/docker-compose.md)</sup><sup>[[3]](https://github.com/langgenius/dify-docs/blob/main/en/getting-started/install-self-hosted/environments.md)</sup>. If you need further assistance, you might want to review the tests related to URL handling in `api/tests/unit_tests/libs/test_yarl.py` to ensure that URL concatenation and handling are working as expected <sup>[[4]](https://github.com/langgenius/dify/blob/main/api/tests/unit_tests/libs/test_yarl.py)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Author
Owner

@iamjoel commented on GitHub (Jun 20, 2024):

Can you share me the tool to help me to reproduction the bug? @guobaozu

@iamjoel commented on GitHub (Jun 20, 2024): Can you share me the tool to help me to reproduction the bug? @guobaozu
Author
Owner

@guobaozu commented on GitHub (Jul 1, 2024):

Sorry for the late reply. I just checked and it has been fixed and can be displayed normally. Thank you for your hard work!

@guobaozu commented on GitHub (Jul 1, 2024): Sorry for the late reply. I just checked and it has been fixed and can be displayed normally. Thank you for your hard work!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#4147