If the uploaded txt file is a non-UTF8 file. Uploading is no problem. When talking to a file, the document parser reports an error: Failed to decode plain text file #6760

Closed
opened 2026-02-21 18:17:11 -05:00 by yindo · 1 comment
Owner

Originally created by @wgq910668 on GitHub (Nov 14, 2024).

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

0.10.1

Cloud or Self Hosted

Self Hosted (Source)

Steps to reproduce

If the uploaded txt file is a non-UTF8 file. Uploading is no problem. When talking to a file, the document parser reports an error: Failed to decode plain text file

error message:Failed to decode plain text file

image

✔️ Expected Behavior

No response

Actual Behavior

No response

Originally created by @wgq910668 on GitHub (Nov 14, 2024). ### 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 0.10.1 ### Cloud or Self Hosted Self Hosted (Source) ### Steps to reproduce If the uploaded txt file is a non-UTF8 file. Uploading is no problem. When talking to a file, the document parser reports an error: Failed to decode plain text file error message:Failed to decode plain text file ![image](https://github.com/user-attachments/assets/162052c8-9533-4a32-9961-0954580c1f21) ### ✔️ Expected Behavior _No response_ ### ❌ Actual Behavior _No response_
yindo added the 🐞 buggood first issue labels 2026-02-21 18:17:11 -05:00
yindo closed this issue 2026-02-21 18:17:11 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Nov 14, 2024):

The error you're encountering, "Failed to decode plain text file," occurs because the document parser in Dify attempts to decode text files using UTF-8 encoding. If the file is not encoded in UTF-8, this error will be raised. The specific part of the code responsible for this is the _extract_text_from_plain_text function, which tries to decode the file content using UTF-8 and raises a TextExtractionError if it fails due to a UnicodeDecodeError [1].

Currently, there is no indication of a fallback mechanism for handling non-UTF8 encoded files or a configuration setting to specify the encoding of uploaded text files in Dify. You might need to ensure that your text files are encoded in UTF-8 before uploading them to avoid this issue.

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Nov 14, 2024): <!-- Answer --> The error you're encountering, "Failed to decode plain text file," occurs because the document parser in Dify attempts to decode text files using UTF-8 encoding. If the file is not encoded in UTF-8, this error will be raised. The specific part of the code responsible for this is the `_extract_text_from_plain_text` function, which tries to decode the file content using UTF-8 and raises a `TextExtractionError` if it fails due to a `UnicodeDecodeError` <sup>[[1]](https://github.com/langgenius/dify/blob/main/api/core/workflow/nodes/document_extractor/node.py)</sup>. Currently, there is no indication of a fallback mechanism for handling non-UTF8 encoded files or a configuration setting to specify the encoding of uploaded text files in Dify. You might need to ensure that your text files are encoded in UTF-8 before uploading them to avoid this issue. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#6760