langgenius / dify

Dify is an open-source LLM app development platform. Dify's intuitive interface combines AI workflow, RAG pipeline, agent capabilities, model management, observability features and more, letting you quickly go from prototype to production.
https://dify.ai
Other
51.58k stars 7.45k forks source link

File validation failed when using custon file types in input #10637

Open LiuBodong opened 1 day ago

LiuBodong commented 1 day ago

Self Checks

Dify version

0.11.1

Cloud or Self Hosted

Self Hosted (Docker), Self Hosted (Source)

Steps to reproduce

✔️ Expected Behavior

upload and validate correctly

❌ Actual Behavior

图片

dosubot[bot] commented 1 day ago

@LiuBodong Hello there! I'm here to assist you with any bugs, questions, or contributions you may have regarding Dify. Let's dive in and tackle this issue together!

File validation may fail when using custom file types in Dify version 0.11.1 due to how custom file extensions are handled. The code processes custom file types by removing the leading dot if present. This means that if custom file types are provided with a leading dot (e.g., ".txt"), they are stored without the dot (e.g., "txt"). If the validation logic elsewhere expects the file extensions to include the dot, this discrepancy could lead to validation failures [1].

The backend validation logic for file extensions does not expect them to include a leading dot. The getFileExtension function extracts the file extension without a leading dot [2].

To resolve this, ensure that the custom file types are specified without a leading dot in the input field configuration.

To continue talking to Dosu, mention @dosu.

crazywoola commented 1 day ago

Why don't you just use the image type?

LiuBodong commented 1 day ago

When validate file extensions, the file extension contains a 'dot', such as: '.png', '.jpg'. but the "allowed_extensions" array DO NOT contains the 'dot', it looks like '["png", "jpg"]'

图片

LiuBodong commented 1 day ago

Why don't you just use the image type?

cause i have to deal with image or a tar binary together

crazywoola commented 1 day ago

I think you can check 2 types, image and other.

crazywoola commented 1 day ago

We had a fix recently #10111

LiuBodong commented 1 day ago

I think you can check 2 types, image and other.

When validate file extensions, the file extension contains a 'dot', such as: '.png', '.jpg'. but the "allowed_extensions" array DO NOT contains the 'dot', it looks like '["png", "jpg"]'

图片

please just check this code and have a test

laipz8200 commented 2 hours ago

We are now processing this issue.