Defect #35100

MailHandler raises NameError exception when generating error message

Added by Dmitry Makurin 24 days ago. Updated 18 days ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Go MAEDA% Done:

0%

Category:Email receiving
Target version:4.1.3
Resolution:Fixed Affected version:4.1.0

Description

Issue #31899 improved errors clarity but it's actually broken. Instead raising UnauthorizedAction its getting Uninitialized variable because project is not defined at lines:
source:trunk/app/models/mail_handler.rb#L230
source:trunk/app/models/mail_handler.rb#L279

Here the fix:

UTF-8
===================================================================
diff --git a/app/models/mail_handler.rb b/app/models/mail_handler.rb
--- a/app/models/mail_handler.rb    (revision 8a2fa565e2bbe8667e6509755769343a7c69fcd3)
+++ b/app/models/mail_handler.rb    (date 1618469355034)
@@ -227,7 +227,7 @@
     unless handler_options[:no_permission_check]
       unless user.allowed_to?(:add_issue_notes, issue.project) ||
                user.allowed_to?(:edit_issues, issue.project)
-        raise UnauthorizedAction, "not allowed to add notes on issues to project [#{project.name}]" 
+        raise UnauthorizedAction, "not allowed to add notes on issues to project [#{issue.project.name}]" 
       end
     end

@@ -282,7 +282,7 @@
     end

     unless handler_options[:no_permission_check]
-      raise UnauthorizedAction, "not allowed to add messages to project [#{project.name}]" unless user.allowed_to?(:add_messages, message.project)
+      raise UnauthorizedAction, "not allowed to add messages to project [#{message.project.name}]" unless user.allowed_to?(:add_messages, message.project)
     end

     if !message.locked?

35100-test.patch Magnifier (1.23 KB) Go MAEDA, 2021-04-20 12:41

Associated revisions

Revision 20959
Added by Go MAEDA 18 days ago

MailHandler raises NameError exception when generating error message (#35100).

Patch by Dmitry Makurin and Go MAEDA.

Revision 20960
Added by Go MAEDA 18 days ago

Merged r20959 from trunk to 4.2-stable (#35100).

Revision 20961
Added by Go MAEDA 18 days ago

Merged r20959 from trunk to 4.1-stable (#35100).

History

#1 Updated by Marius BALTEANU 20 days ago

  • Target version set to 4.1.3

#2 Updated by Marius BALTEANU 20 days ago

  • Affected version set to 4.1.0

#3 Updated by Go MAEDA 19 days ago

35100-test.patch is a test code that catches the reported issue.

#4 Updated by Go MAEDA 18 days ago

  • Subject changed from Fix MailHandler errors message to MailHandler raises NameError exception when generating error message
  • Category set to Email receiving
  • Status changed from Confirmed to Resolved
  • Assignee set to Go MAEDA
  • Resolution set to Fixed

Committed the fix. Thank you for reporting and fixing the issue.

#5 Updated by Go MAEDA 18 days ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF