Project

General

Profile

Actions

Defect #35100

closed

MailHandler raises NameError exception when generating error message

Added by Dmitry Makurin almost 3 years ago. Updated almost 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Email receiving
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed
Affected version:

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?


Files

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

Updated by Marius BĂLTEANU almost 3 years ago

  • Target version set to 4.1.3
Actions #2

Updated by Marius BĂLTEANU almost 3 years ago

  • Affected version set to 4.1.0
Actions #3

Updated by Go MAEDA almost 3 years ago

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

Actions #4

Updated by Go MAEDA almost 3 years 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.

Actions #5

Updated by Go MAEDA almost 3 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF