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.

Dans mon environnement de développement local, lors du travail sur un plugin, je rencontre un comportement étrange similaire concernant Composer.

Le bouton « Créer un sujet » fonctionne dans mon instance Discourse locale, mais si j’essaie d’ajouter un autre bouton « Créer un sujet » ailleurs (en ajoutant du code pour y parvenir), cela pose problème : tous les boutons « Créer un sujet » sur tout le site (local) cessent de fonctionner.

Et j’obtiens cette erreur :

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

Ce problème persiste même si je supprime le code que j’avais ajouté et qui semblait être à l’origine de l’erreur. Autrement dit, une fois que cette erreur apparaît, même si je remets tout le code tel qu’il était auparavant, l’erreur réapparaît à chaque fois que je clique sur le bouton « Créer un sujet ».

La seule chose qui, selon moi, fait disparaître l’erreur, c’est de supprimer complètement le fichier où le nouveau code se trouvait (donc, l’absence du fichier semble fonctionner ; la présence du fichier sans code à l’intérieur maintient l’erreur).

Quelqu’un a-t-il une idée de ce qui se passe ? Cela constitue un gros obstacle à mon développement.