Undefined method `email'

(Pari) #1

After update to the latest version, I’m getting tons of the following error:

Job exception: undefined method email for nil:NilClass

I tested the smtp by sending a test mail through GUI and it reach to my mail address. However in the sidekiq it is reported that some emails haven’t been send

(Alan Tan) #2

Do you have the backtrace for the logs?

(Pari) #3

this one?

/var/www/discourse/app/models/user.rb:957:in `email'
/var/www/discourse/app/models/user.rb:305:in `email_hash'
/var/www/discourse/app/models/user_avatar.rb:17:in `block in update_gravatar!'
/var/www/discourse/lib/distributed_mutex.rb:21:in `synchronize'
/var/www/discourse/lib/distributed_mutex.rb:5:in `synchronize'
/var/www/discourse/app/models/user_avatar.rb:14:in `update_gravatar!'
/var/www/discourse/app/jobs/regular/update_gravatar.rb:12:in `execute'
/var/www/discourse/app/jobs/base.rb:134:in `block (2 levels) in perform'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/rails_multisite-1.1.2/lib/rails_multisite/connection_management.rb:77:in `with_connection'
/var/www/discourse/app/jobs/base.rb:129:in `block in perform'
/var/www/discourse/app/jobs/base.rb:125:in `each'
/var/www/discourse/app/jobs/base.rb:125:in `perform'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/sidekiq-5.0.5/lib/sidekiq/processor.rb:188:in `execute_job'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/sidekiq-5.0.5/lib/sidekiq/processor.rb:170:in `block (2 levels) in process'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/sidekiq-5.0.5/lib/sidekiq/middleware/chain.rb:128:in `block in invoke'
/var/www/discourse/lib/sidekiq/pausable.rb:80:in `call'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/sidekiq-5.0.5/lib/sidekiq/middleware/chain.rb:130:in `block in invoke'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/sidekiq-5.0.5/lib/sidekiq/middleware/chain.rb:133:in `invoke'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/sidekiq-5.0.5/lib/sidekiq/processor.rb:169:in `block in process'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/sidekiq-5.0.5/lib/sidekiq/processor.rb:141:in `block (6 levels) in dispatch'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/sidekiq-5.0.5/lib/sidekiq/job_retry.rb:97:in `local'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/sidekiq-5.0.5/lib/sidekiq/processor.rb:140:in `block (5 levels) in dispatch'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/sidekiq-5.0.5/lib/sidekiq.rb:36:in `block in <module:Sidekiq>'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/sidekiq-5.0.5/lib/sidekiq/processor.rb:136:in `block (4 levels) in dispatch'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/sidekiq-5.0.5/lib/sidekiq/processor.rb:204:in `stats'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/sidekiq-5.0.5/lib/sidekiq/processor.rb:131:in `block (3 levels) in dispatch'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/sidekiq-5.0.5/lib/sidekiq/job_logger.rb:7:in `call'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/sidekiq-5.0.5/lib/sidekiq/processor.rb:130:in `block (2 levels) in dispatch'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/sidekiq-5.0.5/lib/sidekiq/job_retry.rb:72:in `global'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/sidekiq-5.0.5/lib/sidekiq/processor.rb:129:in `block in dispatch'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/sidekiq-5.0.5/lib/sidekiq/logging.rb:44:in `with_context'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/sidekiq-5.0.5/lib/sidekiq/logging.rb:38:in `with_job_hash_context'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/sidekiq-5.0.5/lib/sidekiq/processor.rb:128:in `dispatch'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/sidekiq-5.0.5/lib/sidekiq/processor.rb:168:in `process'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/sidekiq-5.0.5/lib/sidekiq/processor.rb:85:in `process_one'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/sidekiq-5.0.5/lib/sidekiq/processor.rb:73:in `run'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/sidekiq-5.0.5/lib/sidekiq/util.rb:16:in `watchdog'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/sidekiq-5.0.5/lib/sidekiq/util.rb:25:in `block in safe_thread'

(Alan Tan) #4

Hmm are you using SSO on your site? We’ve seen this with one of our customers as well but have not managed to get a consistent reproduction of how the user ends up in that state.

(Pari) #5

I’m using wordpress discourse sso plugin. However ppl sign in to wordpress with that.

Should I worry about anything? are my emails not being sent to the users?

(Pari) #6

btw maybe this would be also related. I cant update my instance with web GUI

(Alan Tan) #7

You should be able to see from the error how many users are affected. They basically have no emails record associated. I’ll have a look at the code for the wordpress sso plugin.

(Rafael dos Santos Silva) #8

Also you are running an old image, with Ruby 2.3.

Please update to latest, following the instructions provided.

(Pari) #9

So I found that one user is without email address. How could this happen?

Most of my users are signed up with api calls and email is necessary when they sign up.

(Alan Tan) #10

Hmm which API calls are you using? If possible could you provide me with the exact script you’re using? This is basically a bug in Discourse but we’ve not been able to reproduce it.

(Pari) #11

Here it is:

    public static function Signup($name, $user_name, $user_email, $user_pwd){
        $data = array(  'name'=>$name,
			'active'=> true,

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, self::$discourse_url."users");
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
        $ip = $_SERVER['REMOTE_ADDR'];
        curl_setopt($ch, CURLOPT_HTTPHEADER, array("X-FORWARDED-FOR: $ip"));
        $response = curl_exec($ch);

        return $response;

(Pari) #12

I’m doing this in my server as stated in that post:

cd /var/discourse
git pull
./launcher rebuild app

However still web GUI upgrade is showing same message.

(Jeff Atwood) #13

Is this another related Discourse-WP plugin bug @Simon_Cossar? Where users are being created without passwords, or maybe even emails?

(Simon Cossar) #14

There shouldn’t be anywhere in the wp-discourse code that users are created without passwords - unless they are being created through SSO. The parameters send with the SSO payload haven’t changed recently. Users created through the API have a 20 character password. If that password is left of the POST params Discourse returns an error - as it should.

(Simon Cossar) #15

It’s not possible to create a user through either the API or SSO without supplying an email address.

With SSO it would produce the following error:
Record was invalid: User {:primary_email=>"can't be blank"}

With the API:
ActionController::ParameterMissing - param is missing or the value is empty: email

(Alan Tan) #16

Hmm what is the exact URL here?

(Pari) #17

Thats simply the root of my discourse instance:

(Alan Tan) #18

So you’re doing a POST request to https://talk.zabanshenas.com/users?

(Pari) #19

Yes. With all information needed for signing up a user.