Issue merging user accounts, web interace and rake console

AI-generated summary

cmahns is experiencing persistent failures when attempting to merge user accounts via both the web interface and rake users:merge, encountering an ArgumentError: topic during the process. The issue affects multiple user pairs, including n_stylo into nat1 2 and NikS into NikS1 5. The error originates in post_owner_changer.rb, suggesting a problem with topic associations during post migration. A recurring warning about the discourse-user-notes plugin being named discourse-staff-notes in the filesystem was noted 6, though RGJ clarifies this is likely cosmetic and not the root cause. JammyDodger suggests testing with LOAD_PLUGINS=0 to rule out plugin interference 9, while also cautioning that disabling plugins may affect data from other extensions like polls or topic voting 10. A potential solution comes from per1234, who traced a similar hang to “orphaned” posts — posts linked to non-existent topics — and recommends using a Data Explorer query to identify and clean them before retrying the merge.

Currently running into an issue of a failed user merge of a very active user account into a new user. The user no longer has access to the previous user account and email, and due to my instance being on Auth0 SSO (which I do not have access to) I need to merge the users.

This hangs running in the browser, and I seem to be unable to kick the merge off using the application console as well.

Error Log, from running rake users:merge
# rake users:merge['redacted-source-user','redacted-target-user'] --trace
Plugin name is 'discourse-user-notes', but plugin directory is named 'discourse-staff-notes'
** Invoke users:merge (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute users:merge
rake aborted!
ArgumentError: topic
/var/www/discourse/app/services/post_owner_changer.rb:12:in `block in initialize'
/var/www/discourse/app/services/post_owner_changer.rb:11:in `each'
/var/www/discourse/app/services/post_owner_changer.rb:11:in `initialize'
/var/www/discourse/app/services/user_merger.rb:83:in `new'
/var/www/discourse/app/services/user_merger.rb:83:in `change_post_owner'
/var/www/discourse/app/services/user_merger.rb:71:in `block in move_posts'
/var/www/discourse/app/services/user_merger.rb:69:in `each'
/var/www/discourse/app/services/user_merger.rb:69:in `move_posts'
/var/www/discourse/app/services/user_merger.rb:14:in `merge!'
/var/www/discourse/lib/tasks/users.rake:57:in `block in <main>'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:279:in `block in execute'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:279:in `each'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:279:in `execute'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `synchronize'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:188:in `invoke'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:160:in `invoke_task'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `each'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block in top_level'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:125:in `run_with_threads'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:110:in `top_level'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:83:in `block in run'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:186:in `standard_exception_handling'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:80:in `run'
bin/rake:13:in `<top (required)>'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.13/lib/bundler/cli/exec.rb:58:in `load'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.13/lib/bundler/cli/exec.rb:58:in `kernel_load'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.13/lib/bundler/cli/exec.rb:23:in `run'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.13/lib/bundler/cli.rb:492:in `exec'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.13/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.13/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.13/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.13/lib/bundler/cli.rb:34:in `dispatch'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.13/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.13/lib/bundler/cli.rb:28:in `start'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.13/exe/bundle:45:in `block in <top (required)>'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.13/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.13/exe/bundle:33:in `<top (required)>'
/usr/local/bin/bundle:25:in `load'
/usr/local/bin/bundle:25:in `<main>'
Tasks: TOP => users:merge

Hate to bump this but still experiencing the same issue. Now getting a new Argument error after the rake aborted message though!

Including the two usernames in this next error log just to see if it’s somehow the user’s name that’s the issue.

Error log, from running rake users:merge
# rake users:merge['n_stylo','nat1'] --trace                                                                                                                
Plugin name is 'discourse-user-notes', but plugin directory is named 'discourse-staff-notes'                                                                                                 
** Invoke users:merge (first_time)                                                                                                                                                           
** Invoke environment (first_time)                                                            
** Execute environment                                                                                                                                                                       
** Execute users:merge                                                                        
rake aborted!                                                                                                                                                                                
ArgumentError: topic (ArgumentError)                                                                                                                                                         
                                                                                              
      raise ArgumentError.new(arg) if self.instance_variable_get("@#{arg}").blank?
            ^^^^^^^^^^^^^^^^^^^^^^                                                            
/var/www/discourse/app/services/post_owner_changer.rb:12:in `block in initialize'
/var/www/discourse/app/services/post_owner_changer.rb:11:in `each'                                                                                                                           
/var/www/discourse/app/services/post_owner_changer.rb:11:in `initialize'                   
/var/www/discourse/app/services/user_merger.rb:83:in `new'                                                                                                                                   
/var/www/discourse/app/services/user_merger.rb:83:in `change_post_owner'                                                                                                                     
/var/www/discourse/app/services/user_merger.rb:71:in `block in move_posts'                                                                                                                   
/var/www/discourse/app/services/user_merger.rb:69:in `each'                                                                                                                                  
/var/www/discourse/app/services/user_merger.rb:69:in `move_posts'                            
/var/www/discourse/app/services/user_merger.rb:14:in `merge!'
/var/www/discourse/lib/tasks/users.rake:57:in `block in <main>'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.1.0/lib/rake/task.rb:279:in `block in execute'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.1.0/lib/rake/task.rb:279:in `each'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.1.0/lib/rake/task.rb:279:in `execute' 
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.1.0/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.1.0/lib/rake/task.rb:199:in `synchronize'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.1.0/lib/rake/task.rb:199:in `invoke_with_call_chain'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.1.0/lib/rake/task.rb:188:in `invoke'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.1.0/lib/rake/application.rb:182:in `invoke_task'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.1.0/lib/rake/application.rb:138:in `block (2 levels) in top_level'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.1.0/lib/rake/application.rb:138:in `each'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.1.0/lib/rake/application.rb:138:in `block in top_level'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.1.0/lib/rake/application.rb:147:in `run_with_threads'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.1.0/lib/rake/application.rb:132:in `top_level'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.1.0/lib/rake/application.rb:83:in `block in run'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.1.0/lib/rake/application.rb:208:in `standard_exception_handling'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.1.0/lib/rake/application.rb:80:in `run'
bin/rake:13:in `<top (required)>'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/lib/bundler/cli/exec.rb:58:in `load'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/lib/bundler/cli/exec.rb:58:in `kernel_load'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/lib/bundler/cli/exec.rb:23:in `run'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/lib/bundler/cli.rb:451:in `exec'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/lib/bundler/vendor/thor/lib/thor/command.rb:28:in `run'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/lib/bundler/vendor/thor/lib/thor.rb:527:in `dispatch'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/lib/bundler/cli.rb:34:in `dispatch'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/lib/bundler/vendor/thor/lib/thor/base.rb:584:in `start'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/lib/bundler/cli.rb:28:in `start'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/exe/bundle:28:in `block in <top (required)>' 
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/exe/bundle:20:in `<top (required)>'
/usr/local/bin/bundle:25:in `load'
/usr/local/bin/bundle:25:in `<main>'
Tasks: TOP => users:merge```

Did you manage to get to the bottom of this in the end?

I haven’t! Error is still ongoing for these two users

Hate to bump this again, but it’s going on for another user on my instance. Error log below:

Error Log from running rake users:merge

root@forum-app:/var/www/discourse# rake users:merge[‘NikS’,‘NikS1’] --trace
Plugin name is ‘discourse-user-notes’, but plugin directory is named ‘discourse-staff-notes’
** Invoke users:merge (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute users:merge
rake aborted!
ArgumentError: topic (ArgumentError)

  raise ArgumentError.new(arg) if self.instance_variable_get("@#{arg}").blank?
        ^^^^^^^^^^^^^^^^^^^^^^

/var/www/discourse/app/services/post_owner_changer.rb:12:in block in initialize' /var/www/discourse/app/services/post_owner_changer.rb:11:in each’
/var/www/discourse/app/services/post_owner_changer.rb:11:in initialize' /var/www/discourse/app/services/user_merger.rb:84:in new’
/var/www/discourse/app/services/user_merger.rb:84:in change_post_owner' /var/www/discourse/app/services/user_merger.rb:72:in block in move_posts’
/var/www/discourse/app/services/user_merger.rb:70:in each' /var/www/discourse/app/services/user_merger.rb:70:in move_posts’
/var/www/discourse/app/services/user_merger.rb:14:in merge!' /var/www/discourse/lib/tasks/users.rake:57:in block in ’
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/rake-13.2.1/lib/rake/task.rb:279:in block in execute' /var/www/discourse/vendor/bundle/ruby/3.3.0/gems/rake-13.2.1/lib/rake/task.rb:279:in each’
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/rake-13.2.1/lib/rake/task.rb:279:in execute' /var/www/discourse/vendor/bundle/ruby/3.3.0/gems/rake-13.2.1/lib/rake/task.rb:219:in block in invoke_with_call_chain’
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/rake-13.2.1/lib/rake/task.rb:199:in synchronize' /var/www/discourse/vendor/bundle/ruby/3.3.0/gems/rake-13.2.1/lib/rake/task.rb:199:in invoke_with_call_chain’
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/rake-13.2.1/lib/rake/task.rb:188:in invoke' /var/www/discourse/vendor/bundle/ruby/3.3.0/gems/rake-13.2.1/lib/rake/application.rb:188:in invoke_task’
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/rake-13.2.1/lib/rake/application.rb:138:in block (2 levels) in top_level' /var/www/discourse/vendor/bundle/ruby/3.3.0/gems/rake-13.2.1/lib/rake/application.rb:138:in each’
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/rake-13.2.1/lib/rake/application.rb:138:in block in top_level' /var/www/discourse/vendor/bundle/ruby/3.3.0/gems/rake-13.2.1/lib/rake/application.rb:147:in run_with_threads’
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/rake-13.2.1/lib/rake/application.rb:132:in top_level' /var/www/discourse/vendor/bundle/ruby/3.3.0/gems/rake-13.2.1/lib/rake/application.rb:83:in block in run’
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/rake-13.2.1/lib/rake/application.rb:214:in standard_exception_handling' /var/www/discourse/vendor/bundle/ruby/3.3.0/gems/rake-13.2.1/lib/rake/application.rb:80:in run’
bin/rake:13:in <top (required)>' /usr/local/lib/ruby/gems/3.3.0/gems/bundler-2.5.18/lib/bundler/cli/exec.rb:58:in load’
/usr/local/lib/ruby/gems/3.3.0/gems/bundler-2.5.18/lib/bundler/cli/exec.rb:58:in kernel_load' /usr/local/lib/ruby/gems/3.3.0/gems/bundler-2.5.18/lib/bundler/cli/exec.rb:23:in run’
/usr/local/lib/ruby/gems/3.3.0/gems/bundler-2.5.18/lib/bundler/cli.rb:455:in exec' /usr/local/lib/ruby/gems/3.3.0/gems/bundler-2.5.18/lib/bundler/vendor/thor/lib/thor/command.rb:28:in run’
/usr/local/lib/ruby/gems/3.3.0/gems/bundler-2.5.18/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in invoke_command' /usr/local/lib/ruby/gems/3.3.0/gems/bundler-2.5.18/lib/bundler/vendor/thor/lib/thor.rb:527:in dispatch’
/usr/local/lib/ruby/gems/3.3.0/gems/bundler-2.5.18/lib/bundler/cli.rb:35:in dispatch' /usr/local/lib/ruby/gems/3.3.0/gems/bundler-2.5.18/lib/bundler/vendor/thor/lib/thor/base.rb:584:in start’
/usr/local/lib/ruby/gems/3.3.0/gems/bundler-2.5.18/lib/bundler/cli.rb:29:in start' /usr/local/lib/ruby/gems/3.3.0/gems/bundler-2.5.18/exe/bundle:28:in block in <top (required)>’
/usr/local/lib/ruby/gems/3.3.0/gems/bundler-2.5.18/lib/bundler/friendly_errors.rb:117:in with_friendly_errors' /usr/local/lib/ruby/gems/3.3.0/gems/bundler-2.5.18/exe/bundle:20:in <top (required)>’
/usr/local/bin/bundle:25:in load' /usr/local/bin/bundle:25:in ’
Tasks: TOP => users:merge

Not sure if there’s some other thing I need to do for users like this, source user is a 7 year old account with 834 posts made, target user has 162 posts.

Sorry for the delay in responding. :folded_hands: This may be a shot in the dark but is the user notes warning at the top of each of these errors meaningful?

I think I’ve seen a prior issue where the user notes plugin didn’t like not having its updated name. Could you amend it in your app.yml, rebuild, and see if that helps?

Here’s the one I was thinking of:

That was a client side issue.
I’ve never seen that server-side warning indicating an actual problem. It’s just something that pops up every rake or rails c command line.

I thought that too, but thought it worth a punt just in case. :game_die: :game_die: :slight_smile: User notes + merging seemed like it could be an unhappy marriage if there were any conflicts for some reason.

Yes, totally. It might be worth running the rake task with LOAD_PLUGINS=0

Would you need to be mindful of other plugins that the user may have data for? Eg. Solved, topic voting [1], polls, etc


  1. ↩︎

This may also be a good avenue to explore: