siliconflow ImagePromptMessageContent is not JSON serializable #83

Closed
opened 2026-02-16 10:18:01 -05:00 by yindo · 4 comments
Owner

Originally created by @holdbelief1 on GitHub (Mar 15, 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.0

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

[siliconflow] Error: PluginInvokeError: {"args":{"description":"[models] Error: Object of type ImagePromptMessageContent is not JSON serializable"},"error_type":"InvokeError","message":"[models] Error: Object of type ImagePromptMessageContent is not JSON serializable"}

✔️ Expected Behavior

No response

Actual Behavior

No response

Originally created by @holdbelief1 on GitHub (Mar 15, 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.0 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce [siliconflow] Error: PluginInvokeError: {"args":{"description":"[models] Error: Object of type ImagePromptMessageContent is not JSON serializable"},"error_type":"InvokeError","message":"[models] Error: Object of type ImagePromptMessageContent is not JSON serializable"} ### ✔️ Expected Behavior _No response_ ### ❌ Actual Behavior _No response_
yindo closed this issue 2026-02-16 10:18:01 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Mar 15, 2025):

Hello @holdbelief1! I'm here to assist you with any bugs, questions, or contributions you have. Whether it's solving bugs, answering questions, or becoming a contributor, I'm here to help while you wait for a human maintainer.

I found a similar unsolved discussion regarding JSON serialization issues in Dify. The discussion mentions that the JSON in the HTTP tool cannot accept objects and can only accept strings, which leads to issues with escape characters in the JSON string processed by the code, preventing normal HTTP requests. You can view the discussion here [1].

For your specific issue with ImagePromptMessageContent not being JSON serializable, you might need to implement a custom serialization method. Dify uses the create_json_message method for handling JSON serialization for custom objects, which might be useful in your case [2]. You may need to extend or modify this method to handle the serialization of ImagePromptMessageContent objects.

To continue talking to Dosu, mention @dosu.


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

@dosubot[bot] commented on GitHub (Mar 15, 2025): <!-- Greeting --> Hello @holdbelief1! I'm here to assist you with any bugs, questions, or contributions you have. Whether it's solving bugs, answering questions, or becoming a contributor, I'm here to help while you wait for a human maintainer. <!-- Answer --> I found a similar unsolved discussion regarding JSON serialization issues in Dify. The discussion mentions that the JSON in the HTTP tool cannot accept objects and can only accept strings, which leads to issues with escape characters in the JSON string processed by the code, preventing normal HTTP requests. You can view the discussion [here](https://github.com/langgenius/dify/discussions/13768) <sup>[[1]](https://github.com/langgenius/dify/discussions/13768)</sup>. For your specific issue with `ImagePromptMessageContent` not being JSON serializable, you might need to implement a custom serialization method. Dify uses the `create_json_message` method for handling JSON serialization for custom objects, which might be useful in your case <sup>[[2]](https://github.com/langgenius/dify-docs/blob/main/en/plugins/schema-definition/tool.md)</sup>. You may need to extend or modify this method to handle the serialization of `ImagePromptMessageContent` objects. <!-- 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/cbc8b517-63a1-46e0-bb9c-166458902282?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/cbc8b517-63a1-46e0-bb9c-166458902282?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/cbc8b517-63a1-46e0-bb9c-166458902282?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/cbc8b517-63a1-46e0-bb9c-166458902282?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/cbc8b517-63a1-46e0-bb9c-166458902282?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/cbc8b517-63a1-46e0-bb9c-166458902282?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/cbc8b517-63a1-46e0-bb9c-166458902282?feedback_type=other)</sup>
Author
Owner

@filwu8 commented on GitHub (Apr 11, 2025):

[volcengine_maas] Error: PluginInvokeError: {"args":{},"error_type":"TypeError","message":"Object of type ImagePromptMessageContent is not JSON serializable"} 我也有相同问题

@filwu8 commented on GitHub (Apr 11, 2025): [volcengine_maas] Error: PluginInvokeError: {"args":{},"error_type":"TypeError","message":"Object of type ImagePromptMessageContent is not JSON serializable"} 我也有相同问题
Author
Owner

@fengzanfeng commented on GitHub (Jun 5, 2025):

Problem Analysis:
If the System Prompt contains image variables, this issue will be triggered. This occurs because Dify only applies JSON conversion logic to the User Prompt but not to the System Prompt, leading to this exception. It can be considered a defect in Dify's implementation.

Temporary Solution:
Open the Chatflow application and remove the image variables from the System Prompt.

Long-term Solution:
The dify-plugin-sdks code needs to be improved by adding conversion logic for System Prompt Messages.

@fengzanfeng commented on GitHub (Jun 5, 2025): **Problem Analysis:** If the System Prompt contains image variables, this issue will be triggered. This occurs because Dify only applies JSON conversion logic to the User Prompt but not to the System Prompt, leading to this exception. It can be considered a defect in Dify's implementation. **Temporary Solution:** Open the Chatflow application and remove the image variables from the System Prompt. **Long-term Solution:** The dify-plugin-sdks code needs to be improved by adding conversion logic for System Prompt Messages.
Author
Owner

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

Hi, @holdbelief1. I'm Dosu, and I'm helping the dify-official-plugins team manage their backlog and am marking this issue as stale.

Issue Summary:

  • You reported a bug in Dify v1.0 (Docker) where ImagePromptMessageContent objects are not JSON serializable, causing PluginInvokeError.
  • A related discussion highlighted JSON serialization limitations and suggested custom serialization via create_json_message.
  • Another user confirmed experiencing the same issue.
  • Analysis showed the problem stems from JSON conversion being applied only to User Prompts, not System Prompts with image variables.
  • A temporary workaround is to remove image variables from System Prompts; long-term fixes involve improving dify-plugin-sdks.

Next Steps:

  • Please let me know if this issue is still relevant with the latest version of dify-official-plugins by commenting here to keep the discussion open.
  • Otherwise, I will automatically close this issue in 5 days.

Thank you for your understanding and contribution!

@dosubot[bot] commented on GitHub (Aug 21, 2025): Hi, @holdbelief1. I'm [Dosu](https://dosu.dev), and I'm helping the dify-official-plugins team manage their backlog and am marking this issue as stale. **Issue Summary:** - You reported a bug in Dify v1.0 (Docker) where ImagePromptMessageContent objects are not JSON serializable, causing PluginInvokeError. - A related discussion highlighted JSON serialization limitations and suggested custom serialization via create_json_message. - Another user confirmed experiencing the same issue. - Analysis showed the problem stems from JSON conversion being applied only to User Prompts, not System Prompts with image variables. - A temporary workaround is to remove image variables from System Prompts; long-term fixes involve improving dify-plugin-sdks. **Next Steps:** - Please let me know if this issue is still relevant with the latest version of dify-official-plugins by commenting here to keep the discussion open. - Otherwise, I will automatically close this issue in 5 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-official-plugins#83