プロジェクト

全般

プロフィール

Vote #79777

完了

MailHandler.safe_receive does not output any error log

Admin Redmine さんが3年以上前に追加. 3年以上前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
Email receiving_29
対象バージョン:
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
29
version_id:
150
issue_org_id:
30457
author_id:
332
assigned_to_id:
332
comments:
5
status_id:
5
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[Closed]

説明

MailHandler.safe_receive has a rescue clause that seems to be intended to catch all exceptions and log it.


  def self.safe_receive(*args)
    receive(*args)
  rescue Exception => e
    logger.error "MailHandler: an unexpected error occurred when receiving email: #{e.message}" if logger
    return false
  end

However, the expression "logger.error" does not log any events because the variable logger is undefined. Although there is a method definition for "logger" at source:tags/4.0.0/app/models/mail_handler.rb#L77, you cannot call the method from MailHandler.safe_receive because MailHandler.safe_receive is a class method and MailHandler#logger is an instance method.

As a result, the expression logger.error in MailHandler#safe_receive never logs errors because the expression itself causes NameError. To avoid this, logger should be replaced with Rails.logger. The attached patch fixes this issue.


journals

Setting the target version to 4.1.0.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
Committed the fix.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------


related_issues

relates,Closed,11497,Dry up logging in MailHandler class
duplicates,Closed,28874,MailHandler does not log exceptions caught

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0