NoMethodError When Rebuilding User Actions

Hi everyone, so I had originally submitted this under #support, but I’m fairly certain it’s a bug now after duplicating it several times on fresh installs. I only started experiencing this after the latest Discourse release. Here are the steps to reproduce:

  1. Go through normal Discourse install and setup (I got the same error when installing on Ubuntu Server 18.04 LTS as well as Ubuntu Server 20.04 LTS)

  2. After the setup is complete, go into the container and run rake user_actions:rebuild and you will get this error:

    # rake user_actions:rebuild --trace
    ** Invoke user_actions:rebuild (first_time)
    ** Invoke environment (first_time)
    ** Execute environment
    ** Execute user_actions:rebuild
    rake aborted!
    NoMethodError: undefined method `log_topic' for UserActionManager:Class
    /var/www/discourse/lib/tasks/user_actions.rake:14:in `block (2 levels) in <top (required)>'
    /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.2.2/lib/active_record/relation/delegation.rb:85:in `each'
    /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.2.2/lib/active_record/relation/delegation.rb:85:in `each'
    /var/www/discourse/lib/tasks/user_actions.rake:14:in `block in <top (required)>'
    /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:281:in `block in execute'
    /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:281:in `each'
    /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:281:in `execute'
    /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
    /usr/local/lib/ruby/2.6.0/monitor.rb:235:in `mon_synchronize'
    /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:199:in `invoke_with_call_chain'
    /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:188:in `invoke'
    /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:160:in `invoke_task'
    /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:116:in `block (2 levels) in top_level'
    /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:116:in `each'
    /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:116:in `block in top_level'
    /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:125:in `run_with_threads'
    /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:110:in `top_level'
    /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:83:in `block in run'
    /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:186:in `standard_exception_handling'
    /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:80:in `run'
    bin/rake:13:in `<top (required)>'
    /usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:in `load'
    /usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:in `kernel_load'
    /usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:28:in `run'
    /usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli.rb:476:in `exec'
    /usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
    /usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
    /usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor.rb:399:in `dispatch'
    /usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli.rb:30:in `dispatch'
    /usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/base.rb:476:in `start'
    /usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli.rb:24:in `start'
    /usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/exe/bundle:46:in `block in <top (required)>'
    /usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/friendly_errors.rb:123:in `with_friendly_errors'
    /usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/exe/bundle:34:in `<top (required)>'
    /usr/local/bin/bundle:23:in `load'
    /usr/local/bin/bundle:23:in `<main>'
    Tasks: TOP => user_actions:rebuild

I saw in some other posts that people suggested running ./launcher rebuild app when getting similar errors, but after doing that, I still got the NoMethodError.

Any thoughts would be greatly appreciated. Thanks in advance!

1 Like

I’m also seeing this error. Running Ubuntu 19.10.

Sorry, this task really should not exist anymore, it has been broken for many many years.

I have removed it.

Rebuilding user actions may be feasible but is very complex especially since plugins such as assign and solved need to be considered.

4 Likes

Thanks for the info, @sam. I didn’t realize that. FYI, the task did work just a few days ago (for me at least) without issues. After an import I was able to run it successfully and it did rebuild user actions as expected.

Instead of running this task then, is there a preferred way to rebuild this data (or place to store it initially during an import) in order for the data to be properly used by Discourse?

For example, I’ve managed to pull in all pre-Discourse post like history and properly map to all fields in the user_action table. The important part of achieving this seemed to be running the above rake command, because it then showed an accurate like history for each user (most liked, likes given, received, etc). If the above rake will be removed, do you mind pointing me in the right direction for where else in the database user actions need to be stored in order for them to display properly in profiles and user stats? Is it just crunched and saved to the user_stats table as integers or is there another place some of this goes?

Thanks!

Our importers in general offer a framework for doing this during migrations. I would review the source on them.

discourse/script/import_scripts at master · discourse/discourse · GitHub

4 Likes

This topic was automatically closed after 4 days. New replies are no longer allowed.