# 即将举行的活动出现500服务器错误

**URL:** https://meta.discourse.org/t/upcoming-events-shows-500-server-error/221026
**Category:** Bug
**Tags:** events
**Created:** [2022年三月15日 19:21 UTC](https://meta.discourse.org/t/upcoming-events-shows-500-server-error/221026 "2022-03-15T19:21:57Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![sbernhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sbernhard/32/208186_2.png) [@sbernhard](https://meta.discourse.org/u/sbernhard)
#### Post date: [2022年三月15日 19:21 UTC](https://meta.discourse.org/t/upcoming-events-shows-500-server-error/221026/1 "2022-03-15T19:21:57Z")

</div>

如果我点击“即将举行的活动”——我猜这是由 discourse-events 提供的——我会收到 500 服务器错误：

```plaintext
Started GET "/discourse-post-event/events.json" for 91.37.126.155 at 2022-03-15 19:02:36 +0000
Processing by DiscoursePostEvent::EventsController#index as JSON
  Rendered text template (Duration: 0.0ms | Allocations: 1)
Completed 500 Internal Server Error in 913ms (ActiveRecord: 0.0ms | Allocations: 82862)
NoMethodError (undefined method `>=' for nil:NilClass)
(eval):17:in `_fast_attributes'
app/controllers/application_controller.rb:395:in `block in with_resolved_locale'
app/controllers/application_controller.rb:395:in `with_resolved_locale'
lib/middleware/omniauth_bypass_middleware.rb:71:in `call'
lib/content_security_policy/middleware.rb:12:in `call'
lib/middleware/anonymous_cache.rb:355:in `call'
config/initializers/100-quiet_logger.rb:23:in `call'
config/initializers/100-silence_logger.rb:31:in `call'
lib/middleware/enforce_hostname.rb:23:in `call'
lib/middleware/request_tracker.rb:177:in `call'

```

正在使用 discourse 2.7.12 以及 discourse-calender 0.2 和 discourse-saml 0.1

有人知道如何解决这个问题吗？

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [2022年三月15日 19:23 UTC](https://meta.discourse.org/t/upcoming-events-shows-500-server-error/221026/2 "2022-03-15T19:23:54Z")

</div>

> [@sbernhard](#):
>
> 一起使用 discourse 2.7.12

您能在我们的默认发布频道 (tests-passed) 上重现此问题吗？

---

<div class="post-metadata">

### Author: ![sbernhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sbernhard/32/208186_2.png) [@sbernhard](https://meta.discourse.org/u/sbernhard)
#### Post date: [2022年三月15日 19:26 UTC](https://meta.discourse.org/t/upcoming-events-shows-500-server-error/221026/3 "2022-03-15T19:26:42Z")

</div>

抱歉。很遗憾，我无法在其他版本上重现此问题。这是一个生产系统，将很快“近期”更新到 2.8.X 🙂

也许其他人可以验证/测试当前版本是否也会出现此问题。或者有代码方面丰富经验的人可以确认这不应该发生。

有趣的是，有些用户帐户会出现此问题，而有些则不会。找不到原因。

---

<div class="post-metadata">

### Author: ![gde](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gde/32/481170_2.png) [@gde](https://meta.discourse.org/u/gde)
#### Post date: [2022年三月20日 18:21 UTC](https://meta.discourse.org/t/upcoming-events-shows-500-server-error/221026/4 "2022-03-20T18:21:50Z")

</div>

> [@Falco](#):
>
> Can you reproduce on our default release channel (tests-passed) ?

就我而言，我也遇到了这个错误，我使用的是 2.9.0Beta2。  
查看 `/logs`，每次我尝试查看即将发生的事件时，我都能找到这个：

```plaintext
NoMethodError (undefined method `>=' for nil:NilClass)
(eval):17:in `_fast_attributes'
app/controllers/application_controller.rb:397:in `block in with_resolved_locale'
app/controllers/application_controller.rb:397:in `with_resolved_locale'
lib/middleware/omniauth_bypass_middleware.rb:71:in `call'
lib/middleware/content_security_policy/middleware.rb:12:in `call'
lib/middleware/anonymous_cache.rb:358:in `call'
config/initializers/100-quiet_logger.rb:23:in `call'
config/initializers/100-silence_logger.rb:31:in `call'
lib/middleware/enforce_hostname.rb:23:in `call'
lib/middleware/request_tracker.rb:198:in `call'

```

---

<div class="post-metadata">

### Author: ![SaraDev](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/saradev/32/335139_2.png) [@SaraDev](https://meta.discourse.org/u/SaraDev)
#### Post date: [2022年三月21日 20:11 UTC](https://meta.discourse.org/t/upcoming-events-shows-500-server-error/221026/5 "2022-03-21T20:11:49Z")

</div>

测试后，我在当前的 Discourse 版本上无法重现此错误。

Discourse - 2.9.0.beta2  
Discourse Calendar - v0.2  
Microsoft Windows 10 Pro - 版本 10.0.18363 Build 18363  
Google Chrome - 版本 99.0.4844.74

导航到 [[discourse.example.com](http://discourse.example.com)]/upcoming-events 似乎可以正常工作，并按预期显示日历。

 ![image](https://global.discourse-cdn.com/meta/original/3X/9/f/9f7299629fda3584a4e42a02ea071a0210249712.png)

---

<div class="post-metadata">

### Author: ![gde](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gde/32/481170_2.png) [@gde](https://meta.discourse.org/u/gde)
#### Post date: [2022年三月27日 20:33 UTC](https://meta.discourse.org/t/upcoming-events-shows-500-server-error/221026/6 "2022-03-27T20:33:31Z")

</div>

嗯……好的。

我觉得我的实例有问题，就像日历在搜索一个不知何故丢失的帖子。

有没有办法理解这个 `NoMethodError (undefined method `>=' for nil:NilClass)`

到底是什么意思？

从这里开始调试的方法是什么？

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [2022年三月27日 20:55 UTC](https://meta.discourse.org/t/upcoming-events-shows-500-server-error/221026/7 "2022-03-27T20:55:30Z")

</div>

您可以尝试安全模式 `[YourSite]/safe-mode`，禁用主题和非官方插件，看看是否能将其缩小到其中一个干扰项？

 ![safe mode](https://global.discourse-cdn.com/meta/original/3X/4/e/4ee0dfd3b94d7a1e21ff065823292fa7823eacb3.jpeg)

---

<div class="post-metadata">

### Author: ![gde](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gde/32/481170_2.png) [@gde](https://meta.discourse.org/u/gde)
#### Post date: [2022年三月28日 20:41 UTC](https://meta.discourse.org/t/upcoming-events-shows-500-server-error/221026/8 "2022-03-28T20:41:35Z")

</div>

我不知道安全模式，非常有趣。

不幸的是，我仍然收到错误消息 ☹

---

<div class="post-metadata">

### Author: ![gde](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gde/32/481170_2.png) [@gde](https://meta.discourse.org/u/gde)
#### Post date: [2022年五月1日 09:28 UTC](https://meta.discourse.org/t/upcoming-events-shows-500-server-error/221026/9 "2022-05-01T09:28:53Z")

</div>

我刚注意到在使用 Chromium 时没有遇到此问题。这对其他人来说可能是一个变通方法。  
我的主浏览器是 Firefox-esr (91.8.0esr)，运行在 debian 11 上。

---

<div class="post-metadata">

### Author: ![Sticchio](https://avatars.discourse-cdn.com/v4/letter/s/3da27b/32.png) [@Sticchio](https://meta.discourse.org/u/Sticchio)
#### Post date: [2022年五月4日 15:11 UTC](https://meta.discourse.org/t/upcoming-events-shows-500-server-error/221026/10 "2022-05-04T15:11:36Z")

</div>

我正在与 @sbernhard 在同一个 discourse 实例（2.7.12）上合作——作为版主，我不是开发者/管理员。到目前为止，“500 内部服务器错误”出现在具有版主权限的账户上。普通用户似乎没有遇到此错误——他们可以在同一时间访问“即将举行的活动”，而具有版主权限的账户则显示错误（至少，我们还没有收到其他错误报告）。

作为版主，我在 Windows 10 Pro 上的 Firefox 100、Edge 101 和最新版 Chromium 101 上遇到了此错误，在 Ubuntu 上的 Firefox 上也遇到了。使用标准用户账户，我在相同的系统上没有遇到此错误。

---

<div class="post-metadata">

### Author: ![Helen22](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/helen22/32/271907_2.png) [@Helen22](https://meta.discourse.org/u/Helen22)
#### Post date: [2023年三月13日 04:00 UTC](https://meta.discourse.org/t/upcoming-events-shows-500-server-error/221026/11 "2023-03-13T04:00:58Z")

</div>

@Sticchio / @sbernhard ，你们找到解决方案了吗？

我目前在一个网站上遇到了类似的问题。

---

<div class="post-metadata">

### Author: ![Sticchio](https://avatars.discourse-cdn.com/v4/letter/s/3da27b/32.png) [@Sticchio](https://meta.discourse.org/u/Sticchio)
#### Post date: [2023年三月30日 16:48 UTC](https://meta.discourse.org/t/upcoming-events-shows-500-server-error/221026/12 "2023-03-30T16:48:08Z")

</div>

不，不幸的是没有。错误仍然发生。但我们仍在 Discourse 2.8.10 上。我不知道它是否在后续版本中得到修复。

---

<div class="post-metadata">

### Author: ![Nacho\_Caballero](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nacho_caballero/32/130189_2.png) [@Nacho\_Caballero](https://meta.discourse.org/u/Nacho_Caballero)
#### Post date: [2023年八月25日 11:39 UTC](https://meta.discourse.org/t/upcoming-events-shows-500-server-error/221026/13 "2023-08-25T11:39:03Z")

</div>

我仍然收到此错误

> [@sbernhard](#):
>
> 如果我点击“即将举行的活动”，我想这是由 discourse-events 提供的，我会收到 500 服务器错误：

我使用的是 Discourse 3.2.0.beta1-dev 和 Chromium 116。

其他人能重现它吗？

---

<div class="post-metadata">

### Author: ![gde](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gde/32/481170_2.png) [@gde](https://meta.discourse.org/u/gde)
#### Post date: [2023年八月26日 07:55 UTC](https://meta.discourse.org/t/upcoming-events-shows-500-server-error/221026/14 "2023-08-26T07:55:48Z")

</div>

> [@Nacho\_Caballero](#):
>
> 我使用的是 Discourse 3.2.0.beta1-dev 和 Chromium 116。
> 
> 其他人能复现吗？

是的。  
Discourse 和 Chromium 版本相同。Firefox 116 也存在同样的问题。
