fix: Resolve issue with file path name [COG-2937] (#1411)

<!-- .github/pull_request_template.md -->

## Description
Resolves issue with file path handling of some uploaded files in Cognee

## Type of Change
<!-- Please check the relevant option -->
- [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
<!-- Please check all boxes that apply before submitting your PR -->
- [ 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 <boris@topoteretes.com>
This commit is contained in:
Igor Ilic 2025-09-17 12:00:06 +02:00 committed by GitHub
parent 88770b1b11
commit c01e78240a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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