fix: windows filename chars - #774
Conversation
|
ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdds filename sanitization for attachments (Windows-invalid characters and reserved device names), lazily creates the storage directory with restrictive permissions, derives on-disk names from sanitized input and records original filenames in metadata, updates Gmail tooling to report the saved filename, and adds tests verifying sanitization and metadata. ChangesAttachment Filename Sanitization
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
core/attachment_storage.py (1)
106-127:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winPersist sanitized filename in metadata for consistency
save_attachment()now sanitizes the on-disk filename, but metadata still stores the originalfilename(Line 166). This creates a mismatch between what is saved and what later consumers read from metadata.Suggested fix
- self._metadata[file_id] = { + display_filename = safe_filename or f"attachment{extension}" + self._metadata[file_id] = { "file_path": str(file_path), - "filename": filename or f"attachment{extension}", + "filename": display_filename, "mime_type": mime_type or "application/octet-stream", "size": len(file_bytes), "created_at": datetime.now(), "expires_at": expires_at, }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@core/attachment_storage.py` around lines 106 - 127, The metadata currently records the original filename while the stored file uses the sanitized/save_name, causing a mismatch; in save_attachment (and where metadata is built), replace the metadata 'filename' value with the actual on-disk name (use save_name when you generate stem + file_id or safe_filename if you don't append the UUID) so metadata reflects the sanitized/stored filename; optionally keep the original user filename in a separate metadata field like 'original_filename' if you need to preserve it.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@core/attachment_storage.py`:
- Around line 106-127: The metadata currently records the original filename
while the stored file uses the sanitized/save_name, causing a mismatch; in
save_attachment (and where metadata is built), replace the metadata 'filename'
value with the actual on-disk name (use save_name when you generate stem +
file_id or safe_filename if you don't append the UUID) so metadata reflects the
sanitized/stored filename; optionally keep the original user filename in a
separate metadata field like 'original_filename' if you need to preserve it.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 9aeb522d-2520-4c0f-b1b2-ceed6b43b461
📒 Files selected for processing (4)
core/attachment_storage.pygmail/gmail_tools.pytests/gmail/test_attachment_fix.pytests/gmail/test_get_gmail_attachment_content.py
Closes #772
Summary by CodeRabbit
Release Notes
Bug Fixes