# SendGrid - NoMethodError（未定义的方法 \`\[\]'，用于 nil:NilClass）

**URL:** https://meta.discourse.org/t/sendgrid-nomethoderror-undefined-method-for-nil-nilclass/285221
**Category:** Bug
**Created:** [2023年十一月11日 22:24 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:** 9

<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: [2025年二月23日 08:48 UTC](https://meta.discourse.org/t/sendgrid-nomethoderror-undefined-method-for-nil-nilclass/285221/9 "2025-02-23T08:48:36Z")

</div>

您弄清楚这个问题了吗？我遇到了同样的错误，在同一行代码上：

> <https://github.com/discourse/discourse/blob/main/app/controllers/webhooks_controller.rb#L29>

我不熟悉 Ruby，但它似乎可以很好地解析 JSON，直到尝试解析错误代码 `Email::SMTP_STATUS_TRANSIENT_FAILURE` 指向：

> <https://github.com/discourse/discourse/blob/main/lib/email.rb#L8>

我在 [Webhook.site](https://webhook.site) 上检查了 Sendgrid 在我测试 Webhook 时实际发送的内容，对于弹跳，它看起来像这样：

```json
[
  {
    "email": "example@test.com",
    "timestamp": 1740136261,
    "smtp-id": "<14c5d75ce93.dfd.64b469@ismtpd-555>",
    "event": "bounce",
    "category": [
      "cat facts"
    ],
    "sg_event_id": "ovGQ2rRo8ytNezHPDq-7Ig==",
    "sg_message_id": "14c5d75ce93.dfd.64b469.filter0001.16648.5515E0B88.0",
    "reason": "500 unknown recipient",
    "status": "5.0.0"
  }
]

```

看起来应该可以工作！

---

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