Service Desk E-Mails getting lost
On a "from source" installation I've noticed some service desk e-mails vanish (sending an e-mail to any of the generated service desk e-mails did not create an issue nor any response of failure). Only the error
Email can not be processed: undefined method `[]' for nil:NilClass
in application.log
left some clues. This error seems to be caused by add_attachments
, if the e-mail has got no attachments, in lib/gitlab/email/handler/reply_processing.rb
- that's as far as I could trace it (not very familiar with ruby). This was discovered for v13.11.4 (not sure when it was introduced; it worked at some stage without problems).
A quick fix that seems to work for us is:
diff --git i/lib/gitlab/email/handler/reply_processing.rb w/lib/gitlab/email/handler/reply_processing.rb
index 9e476dd4e2b..35269513d41 100644
--- i/lib/gitlab/email/handler/reply_processing.rb
+++ w/lib/gitlab/email/handler/reply_processing.rb
@@ -45,7 +45,11 @@ def process_message(**kwargs)
end
def add_attachments(reply)
- attachments = Email::AttachmentUploader.new(mail).execute(**upload_params)
+ begin
+ attachments = Email::AttachmentUploader.new(mail).execute(**upload_params)
+ rescue Exception
+ attachments = []
+ end
reply + attachments.map do |link|
"\n\n#{link[:markdown]}"
To avoid that such errors cause e-mails to get lost without any trace I'd also suggest to always send a response:
diff --git i/app/workers/email_receiver_worker.rb w/app/workers/email_receiver_worker.rb
index 9ceab9bb878..3c9c5e9b35d 100644
--- i/app/workers/email_receiver_worker.rb
+++ w/app/workers/email_receiver_worker.rb
@@ -49,6 +49,8 @@ def handle_failure(raw, error)
when Gitlab::Email::InvalidRecordError
can_retry = true
error.message
+ else
+ s_("EmailError|Unknown error in GitLab: ") + error.message
end
if reason