escape more than expect #14654

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

Originally created by @baonudesifeizhai on GitHub (Jun 16, 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.4.3

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

Image

should return "some "Dify" text" but actually return "some \"Dify\\" text" , "" problem did not fix?

if it was a real bug i would try to fix it

✔️ Expected Behavior

No response

Actual Behavior

No response

Originally created by @baonudesifeizhai on GitHub (Jun 16, 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.4.3 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce ![Image](https://github.com/user-attachments/assets/77e5fc3d-7ef4-41a9-8636-b43b4b813911) should return "some \"Dify\" text" but actually return \"some \\\"Dify\\\\\" text\" , "\" problem did not fix? if it was a real bug i would try to fix it ### ✔️ Expected Behavior _No response_ ### ❌ Actual Behavior _No response_
yindo added the 🐞 bug label 2026-02-21 19:18:11 -05:00
yindo closed this issue 2026-02-21 19:18:11 -05:00
Author
Owner

@baonudesifeizhai commented on GitHub (Jun 16, 2025):

Image
also seems you add three "\" to http method

@baonudesifeizhai commented on GitHub (Jun 16, 2025): ![Image](https://github.com/user-attachments/assets/3330a5ea-69c6-46a4-b78a-2a70a3640f36) also seems you add three "\\\" to http method
Author
Owner

@dosubot[bot] commented on GitHub (Jun 16, 2025):

Hi @baonudesifeizhai! I'm Dosu and I’m helping the dify team.

The extra backslashes you’re seeing are almost always caused by double (or more) JSON serialization—meaning a string is being encoded as JSON, then encoded again, which escapes the escape characters. In Dify’s workflow, this can happen if you use something like json.dumps() in your Python code block and then pass that result into a node or HTTP request that also serializes the data to JSON. The codebase doesn’t add triple escaping by itself; it’s a side effect of serializing an already-serialized string, especially when passing data between nodes or into HTTP requests that expect a dict/object, not a pre-stringified JSON string. You can see this in the code handling for both code execution and HTTP requests: Python3TemplateTransformer and do_http_request.

To avoid this, make sure you’re passing plain Python objects (like dicts) between workflow nodes and only serialize to JSON at the very last step if needed. If you’re already returning a JSON string from a code block, don’t serialize it again in the HTTP node. This should prevent the excess escaping.

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 (Jun 16, 2025): <!-- Greeting --> Hi @baonudesifeizhai! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the dify team. <!-- Answer --> The extra backslashes you’re seeing are almost always caused by double (or more) JSON serialization—meaning a string is being encoded as JSON, then encoded again, which escapes the escape characters. In Dify’s workflow, this can happen if you use something like `json.dumps()` in your Python code block and then pass that result into a node or HTTP request that also serializes the data to JSON. The codebase doesn’t add triple escaping by itself; it’s a side effect of serializing an already-serialized string, especially when passing data between nodes or into HTTP requests that expect a dict/object, not a pre-stringified JSON string. You can see this in the code handling for both code execution and HTTP requests: [Python3TemplateTransformer](https://github.com/langgenius/dify/blob/2440ac43b191691548936587a58ae7b12ea1f866/api/core/helper/code_executor/python3/python3_transformer.py) and [do_http_request](https://github.com/langgenius/dify/blob/2440ac43b191691548936587a58ae7b12ea1f866/api/core/tools/custom_tool/tool.py). To avoid this, make sure you’re passing plain Python objects (like dicts) between workflow nodes and only serialize to JSON at the very last step if needed. If you’re already returning a JSON string from a code block, don’t serialize it again in the HTTP node. This should prevent the excess escaping. <!-- 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/d5b2d555-8cd8-4a09-a18e-e041c85fe6a9?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/d5b2d555-8cd8-4a09-a18e-e041c85fe6a9?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/d5b2d555-8cd8-4a09-a18e-e041c85fe6a9?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/d5b2d555-8cd8-4a09-a18e-e041c85fe6a9?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/d5b2d555-8cd8-4a09-a18e-e041c85fe6a9?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/d5b2d555-8cd8-4a09-a18e-e041c85fe6a9?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/d5b2d555-8cd8-4a09-a18e-e041c85fe6a9?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/issues/21083)
Author
Owner

@baonudesifeizhai commented on GitHub (Jun 16, 2025):

@dosu. do we need to fix that bug? or just let it go?

@baonudesifeizhai commented on GitHub (Jun 16, 2025): [@dosu](https://go.dosu.dev/dosubot). do we need to fix that bug? or just let it go?
Author
Owner

@dosubot[bot] commented on GitHub (Aug 25, 2025):

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

Issue Summary:

  • You reported excessive escaping of quotes in Dify v1.4.3 when self-hosted via Docker.
  • The output shows multiple layers of escaping, e.g., "some \"Dify\\" text" instead of the expected "some "Dify" text".
  • The likely cause is double JSON serialization when passing already stringified JSON through nodes or HTTP requests.
  • The suggested workaround is to pass plain Python objects rather than pre-stringified JSON.
  • No further updates or maintainer feedback have been provided yet.

Next Steps:

  • Please let me know if this issue is still relevant with the latest version of Dify by commenting here.
  • If I don’t hear back within 15 days, I will automatically close this issue.

Thanks for your understanding and contribution!

@dosubot[bot] commented on GitHub (Aug 25, 2025): Hi, @baonudesifeizhai. 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:** - You reported excessive escaping of quotes in Dify v1.4.3 when self-hosted via Docker. - The output shows multiple layers of escaping, e.g., \"some \\\"Dify\\\\\" text\" instead of the expected "some \"Dify\" text". - The likely cause is double JSON serialization when passing already stringified JSON through nodes or HTTP requests. - The suggested workaround is to pass plain Python objects rather than pre-stringified JSON. - No further updates or maintainer feedback have been provided yet. **Next Steps:** - Please let me know if this issue is still relevant with the latest version of Dify by commenting here. - If I don’t hear back within 15 days, I will automatically close this issue. Thanks 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#14654