Sidekiq shows activation emails being sent to email address nil

Hey awesome folks,

Got a fun one for you. Here’s what happened:

  1. Installed discourse using discourse/docs/INSTALL-cloud.md at main · discourse/discourse · GitHub
  2. Tested email with doctor, works and emails recieved.
  3. attempted to activate admin account and sideqik reveals this (with token redacted):
    {“type”=>“signup”, “user_id”=>1, “email_token”=>“REDACTED”, “to_address”=>nil, “current_site_id”=>“default”}

Not sure why nil is a thing for to_address.

Any tips, advice, or suggestions would be most welcome!

I can probably find it, but do you know what the name of the Sidekiq job was that triggered the email?

If you are not able to access the site because you aren’t receiving the activation email, you can create an admin user and password with rake admin:create. Full instructions are here: Create an admin account from the console. That should allow you to login to the site.

It sounds like you’ll still need to sort out what’s going on with email delivery though.

6 Likes

Sorry for the delayed response. The job that triggered it was: Jobs::CriticalUserEmail

So I followed the guide exactly. When it came to registering the admin account, it did not send an email, and Jobs::CriticalUserEmail contained {“type”=>“signup”, “user_id”=>1, “email_token”=>“REDACTED”, “to_address”=>nil, “current_site_id”=>“default”}.

I did force the admin account just so I could see what issues there were. The result is the following:

  • Doctor works and email is received
  • Digest test works and email is received both HTML version and Plain
  • Any registration no email is sent, and the log for emails in the admin section do not even show a message that an email was sent.

Whenever a user tries to register it’s the same result:
Jobs::CriticalUserEmail contained {“type”=>“signup”, “user_id”=>2, “email_token”=>“REDACTED”, “to_address”=>nil, “current_site_id”=>“default”}.

The tail of /var/discourse/shared/standalone/log/rails/production.log shows (with redactions):

Processing by UsersController#check_username as JSON
  Parameters: {"username"=>"bobo", "email"=>"REDACTED"}
Completed 200 OK in 2ms (Views: 0.1ms | ActiveRecord: 0.0ms | Allocations: 636)
Started GET "/session/csrf" for REDACTEDPUBLICIP at 2024-09-26 08:13:03 +0000
Processing by SessionController#csrf as JSON
Completed 200 OK in 1ms (Views: 0.1ms | ActiveRecord: 0.0ms | Allocations: 270)
Started POST "/u" for REDACTEDPUBLICIP at 2024-09-26 08:13:03 +0000
Processing by UsersController#create as */*
  Parameters: {"name"=>"JJ", "email"=>"REDACTED", "password"=>"[FILTERED]", "username"=>"bobo", "password_confirmation"=>"[FILTERED]", "challenge"=>"REDACTED", "timezone"=>"Europe/London"}
Completed 200 OK in 335ms (Views: 0.1ms | ActiveRecord: 0.0ms | Allocations: 23323)
Started POST "/login" for REDACTEDPUBLICIP at 2024-09-26 08:13:04 +0000
Processing by StaticController#enter as HTML
  Parameters: {"username"=>"bobo", "password"=>"[FILTERED]", "redirect"=>"/u/account-created"}
Redirected to https://REDACTEDDOMAIN/u/account-created
Completed 302 Found in 1ms (ActiveRecord: 0.0ms | Allocations: 507)
Started GET "/u/account-created" for REDACTEDPUBLICIP at 2024-09-26 08:13:04 +0000
Processing by UsersController#account_created as HTML
  Rendered layout layouts/application.html.erb (Duration: 14.0ms | Allocations: 4624)
Completed 200 OK in 21ms (Views: 15.1ms | ActiveRecord: 0.0ms | Allocations: 6821)
Started GET "/sidekiq/queues/critical" for REDACTEDPUBLICIP at 2024-09-26 08:13:15 +0000

In the log there, it does show accurate email for the registartaion parameters, but sideqik still reports “to_address”=>nil

1 Like

Are there any errors on your site’s Error Logs page? That page is at /logs. You can get there from the admin sidebar by clicking the Security / Error Logs entry.

1 Like

Oh interesting. I get this:

This image displays a computer screen with a terminal window open, showing a directory listing and a message log with error messages.  (Captioned by AI)

1 Like

Are you able to access the Sidekiq web interface at /sidekiq ? If so, are there any errors being reported on that page?

1 Like

I am, but what I get is this:

Try clicking on the “Enqueued” tab. It’s a link.

1 Like

I get this:

Which is where I discovered the address_to=nil thing.

There’s something wrong with Redis and/or Sidekiq. There are a few other members of this forum who might have ideas about how to debug the issue.

I’d be tempted to ssh into the server and run:

cd /var/discourse
./launcher rebuild app

It couldn’t hurt at this point.

1 Like

Yeah, I’ve done that several times, hence my coming in to ask.

I’ve done a rebuild. I’ve even done a completely new install too.

Seems to happen every single install. No matter what. And I’m just lost now.

And I am incredibly grateful for what you have tried to help me with.

1 Like

That’s surprising. Make sure you are following all of the steps that are outlined here: . discourse/docs/INSTALL-cloud.md at main · discourse/discourse · GitHub.

Also, make sure the server you are installing Discourse on meets the requirements that are outlined here: discourse/docs/INSTALL.md at main · discourse/discourse · GitHub.

It would be great to sort out what’s going wrong.

3 Likes

I can give you the exact process I used. Perhaps something in the process I am doing is wrong. I’m willing to totally accept I’m making a mistake somewhere!

  1. Have domain. It is discourse.domain.dev (domain obviously redacted)
  2. Have an email account setup. I have a mailgun account, so I set up a brand new user for SMTP. The email is discourse@discourse.domain.dev
  3. Have server. It’s the latest Ubuntu (Jammy Jellyfish)
  4. apt install docker.io - None
  5. Git was already installed
  6. user was root
  7. cloned using git clone https://github.com/discourse/discourse_docker.git /var/discourse
  8. navigated to cd /var/discourse
  9. chmod 700 containers
  10. still root user
  11. ran ./discourse-setup
  12. Filled in info as requested: discourse.domain.dev
  13. Discourse Admin Email: my@personal.email
  14. SMTP: smtp.eu.mailgun.org
  15. SMTP PORT: 587
  16. username: noreply@discourse.domain.dev
  17. userpass: REDACTED
  18. notification email: noreply@discourse.domain.dev
  19. Lets encrypt email: my@personal.email
  20. Maxmind ID: Put it in
  21. Max Mind License: Put it in
  22. Verified the input data for the setup.
  23. Pressed Enter.
  24. Waited.
  25. Waited some more
  26. Made a cuppa
  27. Last line of the bootstrap process:
    + /usr/bin/docker run --shm-size=512m -d --restart=always -e LANG=en_US.UTF-8 -e RAILS_ENV=production -e UNICORN_WORKERS=8 -e UNICORN_SIDEKIQS=1 -e RUBY_GC_HEAP_GROWTH_MAX_SLOTS=40000 -e RUBY_GC_HEAP_INIT_SLOTS=400000 -e RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR=1.5 -e DISCOURSE_DB_SOCKET=/var/run/postgresql -e DISCOURSE_DB_HOST= -e DISCOURSE_DB_PORT= -e LETSENCRYPT_DIR=/shared/letsencrypt -e DISCOURSE_FORCE_HTTPS=true -e LC_ALL=en_US.UTF-8 -e LANGUAGE=en_US.UTF-8 -e DISCOURSE_HOSTNAME=discourse.domain.dev -e DISCOURSE_DEVELOPER_EMAILS=my@personal.email -e DISCOURSE_SMTP_ADDRESS=smtp.eu.mailgun.org -e DISCOURSE_SMTP_PORT=587 -e DISCOURSE_SMTP_USER_NAME=noreply@discourse.domain.dev -e DISCOURSE_SMTP_PASSWORD=b7fc73b0905b5ffb5f70300f1f796000-1b5736a5-0a60075a -e DISCOURSE_SMTP_DOMAIN=discourse.example.com -e DISCOURSE_NOTIFICATION_EMAIL=noreply@discourse.domain.dev -e LETSENCRYPT_ACCOUNT_EMAIL=my@personal.email -e DISCOURSE_MAXMIND_ACCOUNT_ID=REDACTED -e DISCOURSE_MAXMIND_LICENSE_KEY=REDACTED -h devsite -e DOCKER_HOST_IP=172.17.0.1 --name app -t -p 80:80 -p 443:443 -v /var/discourse/shared/standalone:/shared -v /var/discourse/shared/standalone/log/var-log:/var/log --mac-address REDACTGED local_discourse/app /sbin/boot REDACTEDLONGSTRING
  28. Ran ./discourse-doctor. It failed because it could not connect to redis.
  29. Ran ./laucher rebuild app and changed nothing in the config
  30. It built. All ok. The only difference was the last redacted long string.
  31. Ran ./discourse-doctor. I recieved the test email from it.
  32. The site was up so went to create user account for the admin.
  33. Clicked Register
  34. It said that it was sending a notification email.
  35. None recieved.
  36. Checked through ./discourse-docter and saw this:
    Discourse version at discourse.domain.dev: NOT FOUND Discourse version at localhost: NOT FOUND
  37. Ran ./launcher enter app
  38. Ran rake admin:create
  39. Put email: my@personal.email
  40. Reset Password as user already exists
  41. Told “Your account now has Admin priviledges!”
  42. Logged in to site at the domain
  43. Go to discourse.domain.dev/logs - see "Sidekiq heartbeat test failed, restarting`
  44. Go to discourse.domain.dev/sidekiq: See:
  45. Go to view Enqueued
  46. Click on “critical” and expand content and see “to_address”=>nil again.

Stop, and reach out.

This is a complete redo on a new machine today. These are the EXACT same steps I used before. Please, if I messed up, let me know! :pray:


System Setup:

  • CPU: 4 Cores
  • RAM: 16 GB
  • OS: Ubuntu LTS 64bit 24.04
  • Storage: NVMe 500G
  • Postgres Version: 13.16-1
  • Redis: 7.0.7
  • Ruby: 3.3.4
1 Like