[ComfyUI] Should not replace ' to " in JSON string #604

Closed
opened 2026-02-16 10:19:52 -05:00 by yindo · 2 comments
Owner

Originally created by @AnotiaWang on GitHub (Aug 29, 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.0

Plugin version

0.2.4

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

When calling the Workflow node, if the input JSON string contains ', it will be replaced by " in clean_json_string(), resulting to corrupted JSON structure.

https://github.com/langgenius/dify-official-plugins/blob/f5a8c9e26c2fe1c19e6026320f3509a4c74f0709/tools/comfyui/tools/comfyui_workflow.py#L45

Image

@yt-koike

✔️ Error log

No response

Originally created by @AnotiaWang on GitHub (Aug 29, 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.0 ### Plugin version 0.2.4 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce When calling the Workflow node, if the input JSON string contains `'`, it will be replaced by `"` in `clean_json_string()`, resulting to corrupted JSON structure. https://github.com/langgenius/dify-official-plugins/blob/f5a8c9e26c2fe1c19e6026320f3509a4c74f0709/tools/comfyui/tools/comfyui_workflow.py#L45 <img width="963" height="487" alt="Image" src="https://github.com/user-attachments/assets/d37c7779-c171-4ab8-8e43-9867de177614" /> @yt-koike ### ✔️ Error log _No response_
yindo added the bug label 2026-02-16 10:19:52 -05:00
yindo closed this issue 2026-02-16 10:19:52 -05:00
Author
Owner

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

You're right—replacing all single quotes with double quotes in JSON strings is problematic and can corrupt valid JSON, especially if single quotes appear inside string values. The current implementation of clean_json_string() in comfyui_workflow.py does this unconditionally, which is likely a bug and not compatible with JSON standards. JSON requires double quotes for keys and string values, and Python's json.loads() expects properly formatted JSON. Arbitrary replacement can break legitimate input and cause parsing errors like the one you reported. The recommended approach is to validate and parse JSON strictly using json.loads() and provide clear error messages for malformed input, rather than trying to "fix" quotes in preprocessing. You can see the problematic code and context 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 (Aug 29, 2025): <!-- Answer --> You're right—replacing all single quotes with double quotes in JSON strings is problematic and can corrupt valid JSON, especially if single quotes appear inside string values. The current implementation of `clean_json_string()` in `comfyui_workflow.py` does this unconditionally, which is likely a bug and not compatible with JSON standards. JSON requires double quotes for keys and string values, and Python's `json.loads()` expects properly formatted JSON. Arbitrary replacement can break legitimate input and cause parsing errors like the one you reported. The recommended approach is to validate and parse JSON strictly using `json.loads()` and provide clear error messages for malformed input, rather than trying to "fix" quotes in preprocessing. You can see the problematic code and context [here](https://github.com/langgenius/dify-official-plugins/pull/1604). <!-- 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/1a75cdf2-5884-42ba-b4e2-a44c215b4c7a?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/1a75cdf2-5884-42ba-b4e2-a44c215b4c7a?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/1a75cdf2-5884-42ba-b4e2-a44c215b4c7a?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/1a75cdf2-5884-42ba-b4e2-a44c215b4c7a?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/1a75cdf2-5884-42ba-b4e2-a44c215b4c7a?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/1a75cdf2-5884-42ba-b4e2-a44c215b4c7a?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/1a75cdf2-5884-42ba-b4e2-a44c215b4c7a?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/1617)
Author
Owner

@yt-koike commented on GitHub (Aug 29, 2025):

Hello @AnotiaWang
Thank you very much for spotting out a bug! I really appreciate it. I'll make a PR to fix it as soon as possible.

@yt-koike commented on GitHub (Aug 29, 2025): Hello @AnotiaWang Thank you very much for spotting out a bug! I really appreciate it. I'll make a PR to fix it as soon as possible.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify-official-plugins#604