From c01e78240ac466e15a0e2b07c4e48a51c5a981ad Mon Sep 17 00:00:00 2001 From: Igor Ilic <30923996+dexters1@users.noreply.github.com> Date: Wed, 17 Sep 2025 12:00:06 +0200 Subject: [PATCH] fix: Resolve issue with file path name [COG-2937] (#1411) ## Description Resolves issue with file path handling of some uploaded files in Cognee ## Type of Change - [x] Bug fix (non-breaking change that fixes an issue) - [ ] New feature (non-breaking change that adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation update - [ ] Code refactoring - [ ] Performance improvement - [ ] Other (please specify): ## Testing Uploaded file that had issue and was successfully resolved ## Pre-submission Checklist - [ x] **I have tested my changes thoroughly before submitting this PR** - [ x] **This PR contains minimal changes necessary to address the issue/feature** - [ x] My code follows the project's coding standards and style guidelines - [ x] I have added tests that prove my fix is effective or that my feature works - [ x] I have added necessary documentation (if applicable) - [ x] All new and existing tests pass - [ x] I have searched existing PRs to ensure this change hasn't been submitted already - [ x] I have linked any relevant issues in the description - [ x] My commits have clear and descriptive messages ## DCO Affirmation I affirm that all code in every commit of this pull request conforms to the terms of the Topoteretes Developer Certificate of Origin. Co-authored-by: Boris --- cognee/infrastructure/files/utils/get_file_metadata.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cognee/infrastructure/files/utils/get_file_metadata.py b/cognee/infrastructure/files/utils/get_file_metadata.py index 1eb7a1f79..23b10a6df 100644 --- a/cognee/infrastructure/files/utils/get_file_metadata.py +++ b/cognee/infrastructure/files/utils/get_file_metadata.py @@ -56,7 +56,12 @@ async def get_file_metadata(file: BinaryIO) -> FileMetadata: file_type = guess_file_type(file) file_path = getattr(file, "name", None) or getattr(file, "full_name", None) - file_name = Path(file_path).stem if file_path else None + + if isinstance(file_path, str): + file_name = Path(file_path).stem if file_path else None + else: + # In case file_path does not exist or is a integer return None + file_name = None # Get file size pos = file.tell() # remember current pointer