Improve IMAP import (folder select and partial success)#497
Draft
sdemagny wants to merge 5 commits into
Draft
Conversation
- Add STARTTLS negotiation for port 143 with use_ssl=True - Create IMAPSecurityError exception for security violations - Refuse to continue unencrypted when SSL is required - Check server STARTTLS capability before attempting upgrade - Fail fast to prevent credential leakage on security downgrade Connection behavior: - Port 993 + use_ssl=True → SSL direct - Port 143 + use_ssl=True → STARTTLS (mandatory) - Port 143 + use_ssl=False → unencrypted (explicit choice) Fixes: SSL WRONG_VERSION_NUMBER error on port 143
Backend improvements: - Catch SSL handshake failures during IMAP4_SSL connection - Provide clear error message suggesting port 143 with STARTTLS - Add authentication failure logging with username context - Wrap login() in try-except to log auth errors before propagating Frontend improvements: - Detect "IMAP authentication failed" message in error responses - Display user-friendly credential error message in UI This helps users understand connection failures and authentication issues with clearer, actionable error messages.
Sentry integration: - Add capture_exception for all IMAP import errors - Track folder selection failures, search failures, message processing errors - Capture errors in MBOX and EML import tasks Folder selection improvements: - Use shlex for more robust folder name parsing - Try exact folder name first with readonly=True - Simplify variations: remove duplicates and invalid combinations - Add INBOX.folder variation for servers using dot separator - Remove unnecessary UTF-7 re-encoding (already handled by server) Fallback strategy: - Catch get_selectable_folders exceptions and fallback to INBOX - Always try INBOX if no folders found - Warn if no messages imported after processing Log level adjustments: - Downgrade folder selection failures from ERROR to WARNING - Add DEBUG logs for folder parsing and selection attempts - These failures are expected for container folders without \Noselect flag Result: More resilient import that continues even when some folders fail, with better visibility in Sentry for real issues.
Frontend: - Show success/failure counts in completion modal - Add warning icon style for partial failures - Pass task metadata through to StepCompleted component Backend: - Report detailed status for partial successes - Track success_count, failure_count in task result - Set appropriate task status based on import results
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.