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

AI-generated summary

Users are encountering errors related to the Discourse composer when attempting to create new topics or replies. ivanrlio reports that post.get fails with “undefined key” when adding a reply, and post appears to be an object with a post number of (...), which resolves to 1. The same user later identifies that the issue stems from two plugins that reopen the composer controller. zogstrip suggests verifying whether post is an Ember object and recommends trying post.post_number instead. Separately, JQ331 describes a similar issue in local development: adding a custom “create topic” button breaks all such buttons site-wide, throwing the error Uncaught Error: Assertion Failed: The key provided to set must be a string or number, you passed undefined. Notably, the error persists even after removing the problematic code — only deleting the file entirely resolves it. Both issues appear to stem from plugin-related interference with the composer’s internal state or Ember object handling, suggesting a need to audit plugin code for improper object manipulation or reopens that break expected behavior.

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.

No meu desenvolvimento local, trabalhando em um plugin, tenho um comportamento estranhamente semelhante em relação ao Composer.

O botão ‘Criar tópico’ funciona na minha instância local do Discourse, mas se eu tentar adicionar um novo botão ‘Criar tópico’ em outro lugar (e adicionar algum código para fazer isso acontecer), tudo se desconfigura, e todos os botões ‘Criar tópico’ em todo o site (local) param de funcionar.

E recebo este erro:

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

Isso continua mesmo se eu remover o código que adicionei e que parecia causar o erro inicialmente. Ou seja, uma vez que obtenho esse erro, mesmo que eu restaure todo o código como estava antes, o erro continua aparecendo sempre que tento clicar no botão ‘Criar tópico’.

A única coisa que, acho eu, faz o erro desaparecer é remover completamente o arquivo onde o novo código estava (ou seja, não ter o arquivo lá parece funcionar; ter o arquivo lá sem nenhum código dentro mantém o erro).

Alguém tem alguma ideia sobre isso? Isso tem sido um grande obstáculo para o meu desenvolvimento.