# SendGrid - NoMethodError (undefined method \`\[\]' for nil:NilClass)

**URL:** <https://meta.discourse.org/t/sendgrid-nomethoderror-undefined-method-for-nil-nilclass/285221>\
**Category:** Bug\
**Created:** [November 11, 2023, 10:24pm UTC](https://meta.discourse.org/t/sendgrid-nomethoderror-undefined-method-for-nil-nilclass/285221 "2023-11-11T22:24:31Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![cultiv](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cultiv/32/483312_2.png) [@cultiv](https://meta.discourse.org/u/cultiv)\
**Post date:** [February 23, 2025, 9:02am UTC](https://meta.discourse.org/t/sendgrid-nomethoderror-undefined-method-for-nil-nilclass/285221/10 "2025-02-23T09:02:22Z")

</div>

Aha.. answering my own question here, the Webhook “Test integration” button lies to you..

Here is the actual payload if I actually send an email to a non-existing email address:

```json
[
  {
    "bounce_classification": "Unclassified",
    "email": "noemail@this.does.not.exist.tld",
    "event": "bounce",
    "reason": "unable to get mx info: failed to get IPs from PTR record: lookup <nil>: unrecognized address",
    "sg_event_id": "Ym91bmNlLTQtNTA0ODUxOTUtZXVvMmlLeGRTYXlQRjRZRTQtLUk3QS0w",
    "sg_message_id": "euo2iKxdSayPF4YE4--I7A.recvd-5f54b5d587-pczjm-1-67BADEEA-6.0",
    "smtp-id": "<870b3a2a-160c-4fc8-bc9a-bd0d5b943b81@forum.umbraco.com>",
    "timestamp": 1740300320,
    "tls": 0,
    "type": "blocked"
  }
]

```

And there we have it: no `status` field.

This is when I purposely use a domain that does not exist, I feel like this should be handled, perhaps `"type": "blocked"` can be the indicator Discourse looks for.

As a different attempt I put some nonsense in front of `outlook.com` and that does give me a working payload:

```json
[
  {
    "bounce_classification": "Invalid Address",
    "email": "oeihoiwehitwiohtriuweruiwerwierhwuerguiwerg@outlook.com",
    "event": "bounce",
    "ip": "149.72.1.78",
    "reason": "550 5.5.0 Requested action not taken: mailbox unavailable (S2017062302). [HK3PEPF0000021E.apcprd03.prod.outlook.com 2025-02-23T08:54:35.950Z 08DD502499E1A0AA]",
    "sg_event_id": "Ym91bmNlLTAtNTA0ODUxOTUtQWJFZ2pVejZUUFd3MnJNTnJabDg4Zy0w",
    "sg_message_id": "AbEgjUz6TPWw2rMNrZl88g.recvd-786d47b7ff-tsp86-1-67BAE249-D.0",
    "smtp-id": "<d8dc253e-6e9a-4418-8478-60780eb4898c@forum.umbraco.com>",
    "status": "5.5.0",
    "timestamp": 1740300876,
    "tls": 1,
    "type": "bounce"
  }
]

```

---

_[View the full topic](https://meta.discourse.org/t/sendgrid-nomethoderror-undefined-method-for-nil-nilclass/285221)._
