Plugin causes odd error on admin pages - cant hydrate plugin without id

AI-generated summary

Oliver_Walker encountered an error while developing a plugin: “Can’t hydrate plugin without an id” when navigating to the admin plugins page. The issue stemmed from missing plugin metadata in the plugin.rb file, which is typically populated via special comment headers. After inspecting /admin/plugins.json, they discovered the plugin ID was unset. The fix involved adding required comment headers like # name:, # about:, # version:, etc., to the plugin.rb file. Oliver_Walker noted that this requirement should be better documented and shared the solution for others Oliver_Walker. Falco had initially asked which plugin was involved, and Oliver_Walker confirmed it was an in-house plugin under development, pending open-source approval.

Hi,

I was creating a plugin and ran into the error:

Error: Can't hydrate plugin without an `id`
    at Class._hydrate (discourse/models/store:330)
    at eval (discourse/models/store:222)
    at Array.map (<anonymous>)
    at Class._resultSet (discourse/models/store:221)
    at eval (discourse/models/store:80)
    at tryCatcher (ember:61303)
    at invokeCallback (ember:61476)
    at publish (ember:61462)
    at eval (ember:55822)
    at invoke (ember:54023)

I was wondering if anyone could tell me what id this is referring to?
the error only appears in the console when I navigate to /admin and then go to the plugins page.
What other information is needed to debug this error?

What is the plugin you installed?

It is one we are currently developing. I will post a link to it as soon as I get the okay to open source it

We figured it out. If we navigate to /admin/plugins.json we could see that the plugin id which is usually populated by the plugin name was not set.

It turns out those fields are populated by having a section of comments in the plugin.rb file… so the fix was adding this in:

# frozen_string_literal: true
# name: example
# about: example about
# version: 1.0
# authors: example 
# url: example

I feel like if you are going to require comments in a file this should be well documented somewhere.. so I’ll leave this solution here.