dify
dify copied to clipboard
Enhance MIME type detection for image URLs to improve robustness
Self Checks
- [X] I have searched for existing issues search for existing issues, including closed ones.
- [X] I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
- [X] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
- [X] Please do not modify this template :) and fill in all the required fields.
1. Is this request related to a challenge you're experiencing? Tell me about your story.
I've encountered errors in our image recognition process:
- "[anthropic] Error: Unsupported image type None, only support image/jpeg, image/png, image/gif, and image/webp"
- "[anthropic] Bad Request Error, Error code: 400 - {'type': 'error', 'error': {'type': 'invalid_request_error', 'message': 'messages.0.content.1.image.source.base64.data: The image was specified using the image/png media type, but does not appear to be a valid png image'}}"
Upon investigation, I found that these errors are caused by incorrect MIME types being passed for the images. In our case, some image URLs have incorrect file extensions due to improper handling during the upload process. This causes mimetypes.guess_type(message_content.data)
to fail in determining the correct type.
While I acknowledge that this issue should primarily be addressed at the image upload stage, I believe enhancing Dify's capabilities could make the platform more robust.
2. Additional context or comments
No response
3. Can you help us with this feature?
- [X] I am interested in contributing to this feature.