Can't delete topics - Error 500, rake aborted!

AI-generated summary

Blechpirat is experiencing an issue where they cannot delete topics on their Discourse forum, resulting in an Error 500. The error occurs both when using the forum software and when running a rake command to delete topics. The issue persists even after dumping, wiping, and reimporting the database.

Blechpirat mentions that the problem started after a large import from SMF and that deleting topics used to work. fzngagan suggests that the issue might be related to a restricted category without any groups attached, pointing to a relevant thread on Meta Discourse.

Blechpirat confirms that the issue is indeed related to the restricted category and that deleting topics works in other parts of the forum. Blechpirat eventually resolves the issue by adding a group to the category and all subcategories, thanking fzngagan for the suggestion.

I can’t delete topics and am wondering why that is.

Using the forum software I get a 500 Internal Server Error

Using the console:

$ cd /var/discourse/
$ sudo -s
# ./launcher enter app
# rake destroy:topics["Redaktion"]
Going to delete all topics in the Redaktion category
There are 102 topics to delete in Redaktion category
Deleting kontaktliste...
rake aborted!
MessageBus::InvalidMessageTarget: MessageBus::InvalidMessageTarget 
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/message_bus-3.3.6/lib/message_bus.rb:373:in `publish'
/var/www/discourse/app/models/topic_tracking_state.rb:216:in `publish_delete'
/var/www/discourse/lib/post_destroyer.rb:195:in `perform_delete'
/var/www/discourse/lib/post_destroyer.rb:73:in `destroy'
/var/www/discourse/app/services/destroy_task.rb:25:in `block in destroy_topics'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.1/lib/active_record/relation/batches.rb:71:in `block (2 levels) in find_each'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.1/lib/active_record/relation/batches.rb:71:in `each'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.1/lib/active_record/relation/batches.rb:71:in `block in find_each'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.1/lib/active_record/relation/batches.rb:138:in `block in find_in_batches'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.1/lib/active_record/relation/batches.rb:245:in `block in in_batches'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.1/lib/active_record/relation/batches.rb:229:in `loop'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.1/lib/active_record/relation/batches.rb:229:in `in_batches'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.1/lib/active_record/relation/batches.rb:137:in `find_in_batches'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.1/lib/active_record/relation/batches.rb:70:in `find_each'
/var/www/discourse/app/services/destroy_task.rb:19:in `destroy_topics'
/var/www/discourse/lib/tasks/destroy.rake:11:in `block in <main>'
/usr/local/bin/bundle:23:in `load'
/usr/local/bin/bundle:23:in `<main>'
Tasks: TOP => destroy:topics
(See full trace by running task with --trace)

So, what did I wrong?

rails c
[1] pry(main)> Topic.find(84010).destroy

Killed that topic, but I still can’t delete stuff from the browser.

Its on a desktop pc running on Slack, sitting right next to me, so no provider.

It contains a rather large import from smf. Deleting topics used to work, suddenly stopped. I’m trying to reorganise the import into a structure more suitable to discourse - the old forum had a lot of depth in its structure.

I have now dumped, wiped and reimported the database. That made everything a little bit faster, but the problem remains.

Take a look at this. Are you trying to work with a restricted category which hasn’t got any groups attached to it?

Yes!

I have just tried to delete a topic somewhere else on that forum, and that works. It might indeed be a problem with the import from smf that attached the groups in a weird way.

Thanks for the pointer!

Indeed, adding a group to the category (and all subcategories) did work. Thank you very much.