Skip to content

list_users_by_email returns nil when successful #795

Description

@francois

Checklist

  • I have looked into the Readme and Examples, and have not found a suitable solution or answer.
  • I have looked into the API documentation and have not found a suitable solution or answer.
  • I have searched the issues and have not found a suitable solution or answer.
  • I have searched the Auth0 Community forums and have not found a suitable solution or answer.
  • I agree to the terms within the Auth0 Code of Conduct.

Description

#list_users_by_email returns nil in the success case.

The root cause seems to be this line:

https://github.com/auth0/ruby-auth0/blame/5ae44e930b3272f9aff0e1a4fc082342afdf233b/lib/auth0/users/client.rb#L178

Notice this line does return if code.between?(200, 299).

Reproduction

#!/usr/bin/env ruby
require 'bundler/inline'

gemfile do
  source 'https://rubygems.org'
  gem 'auth0', '= 6.0.0'
end

# v6 mistakenly does not require this file as part of the gem's default
# load, so it must be required explicitly.
require 'auth0/version'
puts "Auth0::VERSION = #{Auth0::VERSION}"

domain = ENV.fetch('AUTH0_DOMAIN')
client_id = ENV.fetch('AUTH0_CLIENT_ID')
client_secret = ENV.fetch('AUTH0_CLIENT_SECRET')
email = ENV.fetch('AUTH0_TEST_EMAIL')

auth0_client = Auth0::Client.new(
  client_id: client_id,
  client_secret: client_secret,
  domain: domain
)

list = auth0_client.users.list_users_by_email(email: email)

if list.nil?
  puts 'nil list'
else
  puts "#{list.size} items"
end
#!/usr/bin/env ruby
require 'bundler/inline'

gemfile do
  source 'https://rubygems.org'
  gem 'auth0', '= 5.20.0'
end

require 'auth0/version'
puts "Auth0::VERSION = #{Auth0::VERSION}"

domain = ENV.fetch('AUTH0_DOMAIN')
client_id = ENV.fetch('AUTH0_CLIENT_ID')
client_secret = ENV.fetch('AUTH0_CLIENT_SECRET')
email = ENV.fetch('AUTH0_TEST_EMAIL')

auth0_client = Auth0::Client.new(
  client_id: client_id,
  client_secret: client_secret,
  domain: domain
)

list = auth0_client.users_by_email(email)

if list.nil?
  puts 'nil list'
else
  puts "#{list.size} items"
end

Results:

$ AUTH0_DOMAIN=aloft-toolkit-prod.us.auth0.com AUTH0_CLIENT_ID=... AUTH0_CLIENT_SECRET=... AUTH0_TEST_EMAIL=engineering@appraisify.com ruby repro5.rb
Auth0::VERSION = 5.20.0
1 items
$ AUTH0_DOMAIN=aloft-toolkit-prod.us.auth0.com AUTH0_CLIENT_ID=... AUTH0_CLIENT_SECRET=... AUTH0_TEST_EMAIL=engineering@appraisify.com ruby repro6.rb
Auth0::VERSION = 6.0.0
nil list
$ ruby --version
ruby 4.0.6 (2026-07-14 revision 03b6d3f889) +PRISM [arm64-darwin24]

Additional context

This is running as part of a Rails application

ruby-auth0 version

6.0.0

Ruby version

4.0.6

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis points to a verified bug in the code

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions