Cannot call get with undefined key / Post.get is not a function

On my local machine I am using the latest version of Discourse. When I attempt to add a reply within a topic, I get the following error message:

The post.get error occurs in this bit of code:

I did a console.log(post) to see what it contained and the result was an object that has a post number of (...) . EDIT: Clicking on (…) yielded 1.

Additionally, when I try to add a New Topic (within the pipeline or in a topic), I get the error:

Would anyone know how to rectify this? Thanks!

Are you sure post is an Ember object? Have you tried post.post_number?

Isolated it down to something in two of our plugins, both of which reopen the composer controller.

2 个赞

在我的本地开发环境中,处理插件时,我发现 Composer 出现了类似的奇怪行为。

“创建主题”按钮在我的本地 Discourse 实例中是有效的,但如果我尝试在其他位置添加一个新的“创建主题”按钮(并添加一些代码来实现),就会出问题,导致整个(本地)站点中的所有“创建主题”按钮都失效了。

我收到了以下错误:

Uncaught Error: Assertion Failed: The key provided to set must be a string or number, you passed undefined

即使我移除了最初似乎导致该错误的代码,这个问题依然存在。也就是说,一旦遇到这个错误,即使我将所有代码恢复到之前的状态,每次点击“创建主题”按钮时,该错误仍会反复出现。

我认为,唯一能让错误消失的方法是完全删除包含新代码的文件(即:文件不存在时似乎正常;文件存在但内容为空时,错误依然存在)。

有人知道这是怎么回事吗?这给我的开发工作带来了很大的阻碍。