# Chat Summary skipping bug

**URL:** <https://meta.discourse.org/t/chat-summary-skipping-bug/356257>\
**Category:** Bug\
**Tags:** chat\
**Created:** [March 7, 2025, 2:05pm UTC](https://meta.discourse.org/t/chat-summary-skipping-bug/356257 "2025-03-07T14:05:13Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)\
**Post date:** [March 7, 2025, 2:05pm UTC](https://meta.discourse.org/t/chat-summary-skipping-bug/356257/1 "2025-03-07T14:05:13Z")

</div>

Chat Summary emails are being skipped for users with a valid email:

![image](https://global.discourse-cdn.com/meta/original/4X/b/a/5/ba5521a804ce46250dc282746fc29b5ef9d406ce.png)

I’ve done some analysis and I believe I know why:

Here’s ultimately where the skipping happens:

> <https://github.com/discourse/discourse/blob/ffdc97f37296e9568d7a5dcec4d1e90e973a6893/lib/email/sender.rb#L52>

This is because `message.to` is blank.

`message.to` is blank because the arguments sent to `send_user_email` do not include `to_address` and this is never enriched with the user’s primary email, e.g.:

```plaintext
args: {"type"=>"chat_summary", "user_id"=>3, "force_respect_seen_recently"=>true, "current_site_id"=>"default"}

```

> <https://github.com/discourse/discourse/blob/ffdc97f37296e9568d7a5dcec4d1e90e973a6893/app/jobs/regular/user_email.rb#L47>

This is called by Chat Mailer, and you will notice that `to_address` is missing:

> <https://github.com/discourse/discourse/blob/ffdc97f37296e9568d7a5dcec4d1e90e973a6893/plugins/chat/lib/chat/mailer.rb#L16>

and that is maybe fine, but by the time you get to the top of `send_user_email`, I believe `to_address` should be enriched with the user email so that when it is passed forward, the emailer is given access to this property and the emailing succeeds.

When I added this small monkey-patch to `send_user_email`, the problem goes away:

```ruby
      # CORE BUG: if we don't set to_address, ultimately the email won't send and will be skipped.
      # This is a core bug and we will need to raise it on Meta.
      if args[:to_address].blank? && user&.primary_email&.email
        args[:to_address] = user&.primary_email&.email
      end

```

---

_[View the full topic](https://meta.discourse.org/t/chat-summary-skipping-bug/356257)._
