ArgumentError : 无效时区:US/Pacific-New 导致 500 错误

我有一个标准的安装,我刚刚升级了它,但由于时区问题而失败。我认为可能只是一个用户,但我不确定。

这只是针对一个用户。当我查看他的个人资料时,他的时区未设置。当我设置时区时,问题就消失了。

Started GET "/t/37040.json?track_visit=true&forceLoad=true" for 204.98.75.5 at 2023-03-23 21:36:37 +0000
Processing by TopicsController#show as JSON
  Parameters: {"track_visit"=>"true", "forceLoad"=>"true", "id"=>"37040"}
Completed 500 Internal Server Error in 48ms (ActiveRecord: 0.0ms | Allocations: 8345)
ArgumentError (Invalid Timezone: US/Pacific-New)
(eval):82:in `_fast_attributes'
app/serializers/post_stream_serializer_mixin.rb:54:in `block in posts'
app/serializers/post_stream_serializer_mixin.rb:47:in `map'
app/serializers/post_stream_serializer_mixin.rb:47:in `posts'
app/serializers/post_stream_serializer_mixin.rb:18:in `post_stream'
(eval):3:in `_fast_attributes'
app/controllers/application_controller.rb:545:in `render_json_dump'
app/controllers/topics_controller.rb:1242:in `block (2 levels) in perform_show_response'
app/controllers/topics_controller.rb:1232:in `perform_show_response'
app/controllers/topics_controller.rb:187:in `show'
app/controllers/application_controller.rb:414:in `block in with_resolved_locale'
app/controllers/application_controller.rb:414:in `with_resolved_locale'
lib/middleware/omniauth_bypass_middleware.rb:74:in `call'
lib/content_security_policy/middleware.rb:12:in `call'
lib/middleware/anonymous_cache.rb:369:in `call'
config/initializers/100-quiet_logger.rb:20:in `call'
config/initializers/100-silence_logger.rb:29:in `call'
lib/middleware/enforce_hostname.rb:24:in `call'
lib/middleware/request_tracker.rb:228:in `call'
Failed to handle exception in exception app middleware : ArgumentError : Invalid Timezone: US/Pacific-New
  Rendered text template (Duration: 0.0ms | Allocations: 1)
Started GET "/latest.json" for 172.220.127.141 at 2023-03-23 21:37:00 +0000
Processing by ListController#latest as JSON

编辑:也许他将时区设置为那个无效值了?我尝试了另一个时区为空的用户,没有出现错误。

3 个赞

您从哪个版本升级的?

可能相关(而且很旧)FIX: removes us_pacific-new from the list of available timezones by jjaffeux · Pull Request #10514 · discourse/discourse · GitHub

5 个赞

哇。抓得好。我需要学习如何更好地在旧提交中搜索字符串。您是通过 GitHub 用户界面执行此操作的吗?在哪里?

这是最近一个版本中的内容,不超过一个月前。除非某个较新的库强制执行了不同的规则,否则现在出现此问题是没有意义的。

所以,这可能是一个偶然的错误,或者该提交本应删除带有那个现在无效时区的用户设置。

1 个赞
  1. 转到您要搜索的存储库
  2. 在左上方输入搜索词

  1. 点击,然后点击“在此存储库中”

2 个赞

我真不敢相信花了 6 年我才弄明白这一点!

3 个赞

嗯,看来我还是没弄明白。

但是等等!这是我这些年一直错过的秘密:

如果我点击“issues”……终于!

非常感谢。

1 个赞

嗯,我最好的猜测是,曾经有一段时间可以选择 US/Pacific-New 作为时区,而这位用户选择了它。现在,某些库在处理该时区的用户时会失败。

UserOption.where("timezone like '%Pacific-New%'")

找不到其他具有该时区的用户,所以我猜这次它不会再发生在这个网站上了。

1 个赞