fix(imap): handle IMAP parser/read errors without exception tracking (#13473)
When an IMAP server returns malformed or partial protocol responses, Inboxes::FetchImapEmailsJob can raise Net::IMAP::ResponseParseError, Net::IMAP::ResponseReadError, or Net::IMAP::ResponseTooLargeError. Previously these errors fell through to the generic StandardError handler and were captured repeatedly in Sentry. This PR updates app/jobs/inboxes/fetch_imap_emails_job.rb to treat those parser/read exceptions as handled IMAP failures by adding them to the existing IMAP/network rescue block, so they are logged and retried on the next scheduled run without exception tracking noise. fixes: https://chatwoot-p3.sentry.io/issues/7132037793/events/104fb9b4d80a4fb6ba3861c44c6c9b83/ How to reproduce: - Use an IMAP server/inbox that intermittently returns malformed or truncated protocol responses during search/fetch. - Run Inboxes::FetchImapEmailsJob for that channel and observe the raised parser/read exception. How this was tested: - bundle exec ruby -c app/jobs/inboxes/fetch_imap_emails_job.rb - bundle exec rubocop app/jobs/inboxes/fetch_imap_emails_job.rb
This commit is contained in:
@@ -13,7 +13,8 @@ class Inboxes::FetchImapEmailsJob < MutexApplicationJob
|
||||
end
|
||||
rescue *ExceptionList::IMAP_EXCEPTIONS => e
|
||||
Rails.logger.error "Authorization error for email channel - #{channel.inbox.id} : #{e.message}"
|
||||
rescue EOFError, OpenSSL::SSL::SSLError, Net::IMAP::NoResponseError, Net::IMAP::BadResponseError, Net::IMAP::InvalidResponseError => e
|
||||
rescue EOFError, OpenSSL::SSL::SSLError, Net::IMAP::NoResponseError, Net::IMAP::BadResponseError, Net::IMAP::InvalidResponseError,
|
||||
Net::IMAP::ResponseParseError, Net::IMAP::ResponseReadError, Net::IMAP::ResponseTooLargeError => e
|
||||
Rails.logger.error "Error for email channel - #{channel.inbox.id} : #{e.message}"
|
||||
rescue LockAcquisitionError
|
||||
Rails.logger.error "Lock failed for #{channel.inbox.id}"
|
||||
|
||||
Reference in New Issue
Block a user