Q2a import error

I’m using [this q2a import](https://gist.github.com/Communiteq (formerly DiscourseHosting)/769eff2014d5482f0ab776de03dc3349) script and see below error. Please help to fix this issue.

Is it problem with my userbase or script. How to fix. Thanks!

Loading existing groups...
Loading existing users...
Loading existing categories...
Loading existing posts...
Loading existing topics...

importing users
       80 / 447 ( 17.9%)  [208 items/min]  Traceback (most recent call last):
	12: from script/import_scripts/question2answer.rb:601:in `<main>'
	11: from /var/www/discourse/script/import_scripts/base.rb:47:in `perform'
	10: from script/import_scripts/question2answer.rb:70:in `execute'
	 9: from script/import_scripts/question2answer.rb:89:in `import_users'
	 8: from /var/www/discourse/script/import_scripts/base.rb:877:in `batches'
	 7: from /var/www/discourse/script/import_scripts/base.rb:877:in `loop'
	 6: from /var/www/discourse/script/import_scripts/base.rb:878:in `block in batches'
	 5: from script/import_scripts/question2answer.rb:106:in `block in import_users'
	 4: from /var/www/discourse/script/import_scripts/base.rb:247:in `create_users'
	 3: from /var/www/discourse/script/import_scripts/base.rb:247:in `each'
	 2: from /var/www/discourse/script/import_scripts/base.rb:259:in `block in create_users'
	 1: from /var/www/discourse/script/import_scripts/base.rb:290:in `create_user'
/var/www/discourse/script/import_scripts/base.rb:393:in `find_existing_user': undefined method `downcase' for nil:NilClass (NoMethodError)

It looks like https://github.com/discourse/discourse/blob/master/script/import_scripts/question2answer.rb was updated more recently. (Oh, but it doesn’t import passwords).

Some field is empty or missing and shouldn’t be. You can try adding a put statement at line 111 printing out the user data and see if any of those fields are empty. And if they are, then you figure out why.

2 Likes

@pfaffman Thank you for the quick reply. appreciate your help.

official q2a import script never worked for me even for other q2a sites. Your script works well.

If some field is missing or empty, I’m Ok to not import that users, please let me know how to do that. which code line to modify.

btw, I’m not good at coding :frowning: I will just follow your instructions to modify code.
Thanks!

That’s beyond the scope of what can be done here. If you need more help, please see Discourse Migration — Literate Computing, LLC and let me know your needs.

1 Like

@pfaffman I tired below solution at line 111 and it worked. Do you see issue with this code? I’m planning to delete all users with below email id/username after import.

Thanks again for your help!

        if !username
            username = "userempty"
        end

        if !email
            email = "test@example.com"
        end

        puts "username: #{username}"
        puts "email: #{email}"
1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.