Send rejection email for unrecognised errors

Yesterday we had an email to Discourse which errored out while processing with:

Unrecognized error type (RuntimeError: ) when processing incoming email

We only found out about this because the user looked on the site for their reply, couldn’t find it, and alerted me. While it did appear in the logs, I don’t check them particularly regularly.

The simplest ‘solution’ to this I see is sending a rejection message to users if there’s been any error during processing, telling them to try again or alert an admin.

Looking at the source, it seems like not sending a message when there’s an unrecognised error is intentional:

While I understand not giving specific information about the error isn’t really possible, Discourse should at least let the user know their email hasn’t been posted so they don’t naively assume it has.

4 个赞

What was the actual error? Can you share the error info? @zogstrip any thoughts on this, should we do a better error here?

I think the problem being raised isn’t so much the specific error, so much as who is notified when random unexpected errors occur. Only admins, if they look in the logs, get to see that the delivery has failed; senders just get radio silence:

2 个赞

Well yes that is what I meant when I wrote

1 个赞

Would love to get the email that’s triggering that error as this is the first time I’m seeing it.

2 个赞

当然:

处理传入邮件时出现未识别的错误类型 (RuntimeError: )

回溯信息:
  /var/www/discourse/lib/discourse.rb:26:in `execute_command'
  /var/www/discourse/lib/upload_creator.rb:137:in `convert_to_jpeg!'
  /var/www/discourse/lib/upload_creator.rb:42:in `block in create_for'
  /var/www/discourse/lib/distributed_mutex.rb:21:in `synchronize'
  /var/www/discourse/lib/distributed_mutex.rb:5:in `synchronize'
  /var/www/discourse/lib/upload_creator.rb:34:in `create_for'
  /var/www/discourse/lib/email/receiver.rb:580:in `block in create_post_with_attachments'
  /var/www/discourse/lib/email/receiver.rb:573:in `each'
  /var/www/discourse/lib/email/receiver.rb:573:in `create_post_with_attachments'
  /var/www/discourse/lib/email/receiver.rb:551:in `create_reply'
  /var/www/discourse/lib/email/receiver.rb:101:in `process_internal'
  /var/www/discourse/lib/email/receiver.rb:50:in `block in process!'
  /var/www/discourse/lib/distributed_mutex.rb:21:in `synchronize'
  /var/www/discourse/lib/distributed_mutex.rb:5:in `synchronize'
  /var/www/discourse/lib/email/receiver.rb:45:in `process!'
  /var/www/discourse/lib/email/processor.rb:17:in `process!'
  /var/www/discourse/lib/email/processor.rb:11:in `process!'
  /var/www/discourse/app/jobs/scheduled/poll_mailbox.rb:25:in `process_popmail'
  /var/www/discourse/app/jobs/scheduled/poll_mailbox.rb:43:in `block (2 levels) in poll_pop3'
  /usr/local/lib/ruby/2.4.0/net/pop.rb:689:in `block in delete_all'
  /usr/local/lib/ruby/2.4.0/net/pop.rb:688:in `each'
  /usr/local/lib/ruby/2.4.0/net/pop.rb:688:in `delete_all'
  /var/www/discourse/app/jobs/scheduled/poll_mailbox.rb:42:in `block in poll_pop3'
  /usr/local/lib/ruby/2.4.0/net/pop.rb:532:in `start'
  /var/www/discourse/app/jobs/scheduled/poll_mailbox.rb:41:in `poll_pop3'
  /var/www/discourse/app/jobs/scheduled/poll_mailbox.rb:16:in `execute'
  /var/www/discourse/app/jobs/base.rb:154:in `block (2 levels) in perform'

这是一个很奇怪的问题,我尝试用相同的图片进行复现,但未能成功。当用户重新发送该邮件时,一切正常。

@zogstrip 我会通过私信发给你完整的日志,包括原始邮件内容。

正是如此,这也是我将此议题放在 Contribute > Feature 而不是 Contribute > Bug 的原因。

作为一名仅通过邮件使用的用户,我希望当我的邮件未能在 Discourse 上生成帖子时,Discourse 能通知我,以便我知道我的同事并非只是无视我。]

2 个赞

Has there been any progress here? I’m willing to submit a PR implementing this if need be.

1 个赞

@LeoMcA did this error happen recently? Because I can not reproduce it :frowning:

It hasn’t, but we want to ensure it doesn’t happen again.

And to be clear “it” isn’t this specific error, but the problem where an email-in will error out while processing and the user has no idea it hasn’t been posted:

It’s possibly easiest if I explain myself through code. Something like this is the feature I want to add:

https://github.com/LeoMcA/discourse/commit/8a77db9225a75083f6b253d3d885b262b0a96f6f

(To be clear, this doesn’t actually implement the feature - templates, test and such still need to be written, and I’m not even sure if it’s the best way of approaching it - but hopefully it serves as a demonstration.)

3 个赞

Sure, PR welcome to handle this case!

2 个赞

:tada:

https://github.com/discourse/discourse/pull/4984

5 个赞

@LeoMcA what do you think about adding the contact email site setting on the message?

So it will be:

We’re sorry, but your email message to %{destination} (titled %{former_title}) didn’t work.
There was an unrecognized error while processing your email and it wasn’t posted. You should try again, or contact a staff member at %{contact_mail}.

6 个赞

A very good idea indeed, but don’t use the contact email, send them to the /about page which can be hard-coded. The contact info is all there.

4 个赞

https://github.com/discourse/discourse/pull/4994

5 个赞