# MessageBus::InvalidMessageTarget (MessageBus::InvalidMessageTarget)

**URL:** https://meta.discourse.org/t/messagebus-invalidmessagetarget-messagebus-invalidmessagetarget/190199
**Category:** Bug
**Created:** [2021年五月12日 14:38 UTC](https://meta.discourse.org/t/messagebus-invalidmessagetarget-messagebus-invalidmessagetarget/190199 "2021-05-12T14:38:31Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![rinkevandenberg](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rinkevandenberg/32/202206_2.png) [@rinkevandenberg](https://meta.discourse.org/u/rinkevandenberg)
#### Post date: [2021年五月12日 14:38 UTC](https://meta.discourse.org/t/messagebus-invalidmessagetarget-messagebus-invalidmessagetarget/190199/1 "2021-05-12T14:38:31Z")

</div>

在尝试于特定分类下创建新主题时，我遇到了 500 错误。这似乎仅限于该分类，因为我在其他分类中创建主题没有问题。

排查后发现是 MessageBus::InvalidMessageTarget（MessageBus::InvalidMessageTarget）异常。

我将其定位到 lib/models/user\_action.rb 的第 293 行。同一文件的第 265 行有一条待办事项：

> TODO 在某些情况下调用此方法时，user\_id 已被回滚且无效。

我认为这就是导致我遇到问题的原因。能否请您说明一下这种情况是如何发生的，以及我该如何绕过它？

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2021年五月13日 05:22 UTC](https://meta.discourse.org/t/messagebus-invalidmessagetarget-messagebus-invalidmessagetarget/190199/2 "2021-05-13T05:22:21Z")

</div>

看起来您有一个被限制访问的类别，但未找到任何群组。

我推测，复现此问题的步骤可能是：先允许某个特定群组访问该类别，然后删除该群组。

临时解决方案是修复该类别的权限设置；此外，我们也可以在代码层面进行一个简单的修复。

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2021年五月13日 05:50 UTC](https://meta.discourse.org/t/messagebus-invalidmessagetarget-messagebus-invalidmessagetarget/190199/3 "2021-05-13T05:50:19Z")

</div>

这应该根据以下内容进行彻底修复：

> <https://github.com/discourse/discourse/pull/13053>
>
> Under certain conditions admins would miss messages when posting action in
> topic…s where they have permission.
> 
> This also fixes an error where we would sometimes explode when publishing to
> an empty group.

但我不确定我们是否会在未来一两周内合并它。

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2021年七月6日 01:02 UTC](https://meta.discourse.org/t/messagebus-invalidmessagetarget-messagebus-invalidmessagetarget/190199/4 "2021-07-06T01:02:37Z")

</div>


