Discourse-events can cause 500 when deleting a topic in development: uninitialized Calendar::Extractor

While testing some unrelated topic-deletion changes in a local development instance, deleting a topic returned a 500 Internal Server Error.

The development instance which produced the error was running this exact Discourse commit:

The request was:

DELETE /t/35

and the exception is coming from the discourse-events :post_destroyed callback:

NameError (uninitialized constant DiscourseEvents::Calendar::Extractor)

plugins/discourse-events/plugin.rb:639:in 'block (2 levels) in Plugin::Instance#activate!'
lib/plugin/instance.rb:676:in 'block in Plugin::Instance#on'
lib/discourse_event.rb:13:in 'block in DiscourseEvent.trigger'
lib/discourse_event.rb:12:in 'DiscourseEvent.trigger'
lib/post_destroyer.rb:91:in 'PostDestroyer#destroy'
app/controllers/topics_controller.rb:818:in 'TopicsController#destroy'

The relevant callback appears to be attempting to call:

DiscourseEvents::Calendar::Extractor.destroy(post)

The full error page reports:

NameError (uninitialized constant DiscourseEvents::Calendar::Extractor)

The browser consequently receives a 500 even though PostDestroyer#destroy has already reached the point where it triggers :post_destroyed, so the deletion may already have been applied before the callback raises.

This occurred in development. DiscourseEvents::Calendar::Extractor is normally provided by events, so I’m wondering whether this could be related to development-mode reloading/plugin state rather than the implementation itself being absent.

I was working on unrelated topic-deletion code at the time, but the exception itself is entirely within the discourse-events :post_destroyed handler.

Has anyone else encountered DiscourseEvents::Calendar::Extractor becoming undefined in a development instance? Could this be related to development reloading/plugin state, or should the :post_destroyed callback be loading the extractor differently?

1 Like