From f88277c467e81f3d63b0e2f713be3d06c3c19276 Mon Sep 17 00:00:00 2001 From: Igor Ilic Date: Sun, 19 Oct 2025 23:10:53 +0200 Subject: [PATCH] fix: Resolve issue with plain text files not having magic file info --- cognee/infrastructure/files/utils/guess_file_type.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cognee/infrastructure/files/utils/guess_file_type.py b/cognee/infrastructure/files/utils/guess_file_type.py index edd2d89b0..dcdd68cad 100644 --- a/cognee/infrastructure/files/utils/guess_file_type.py +++ b/cognee/infrastructure/files/utils/guess_file_type.py @@ -124,6 +124,12 @@ def guess_file_type(file: BinaryIO) -> filetype.Type: """ file_type = filetype.guess(file) + # If file type could not be determined consider it a plain text file as they don't have magic number encoding + if file_type is None: + from filetype.types.base import Type + + file_type = Type("text/plain", "txt") + if file_type is None: raise FileTypeException(f"Unknown file detected: {file.name}.")