Unable to search users by email anymore, only by name

Several weeks ago, it was possible for us to search for users by email and/or name in the users dropdown (screenshot of the said dropdown below).

We experienced a bug which was fixed, but after this fix, we can’t search for users by email anymore, only by name (which can return unexpected results from users outside of the main scope (in our case, organizations)).

Expected behavior

We should be able to search for users in this dropdown by email and name:

Actual behavior

Searching a user by mail (even if the said mail belongs to a user who is part of the same organization)

Failure Logs

No failure logs, the dropdown seems to work normally

Context

  • Package: forest-rails
  • Package Version: 6.3.3
  • Database Dialect: PostgreSQL
  • Database Version: 12
  • Project Name: Elevo

Thanks in advance :slight_smile:

1 Like

Hello!

We’re currently investigating your issue

Thanks @anon39940173 ! :slight_smile:

Hi @anon39940173 !

Do you have any news on this issue ?

Thanks in advance :smile:

I deployed a rails test project to replicate your issue, but failed to find the issue.

I though that it could be related to the reference field of the target model, but that does not seems to have an influence.

When you perform the search by email in a dev environnement, could you show me the SQL query which gets printed to the console?

In my machine it looks like this:

The query should include all eligible fields (in my case, firstname, lastname and email)

I searched for a user by email in the same input as my 1st screen short, and the query made is this one (I formatted it a little bit because it’s pretty big):

SELECT "users"."id" AS t0_r0,
 "users"."email" AS t0_r1,
 "users"."encrypted_password" AS t0_r2,
 "users"."reset_password_token" AS t0_r3,
 "users"."reset_password_sent_at" AS t0_r4,
 "users"."last_sign_in_at" AS t0_r5,
 "users"."confirmation_token" AS t0_r6,
 "users"."confirmed_at" AS t0_r7,
 "users"."confirmation_sent_at" AS t0_r8,
 "users"."unconfirmed_email" AS t0_r9,
 "users"."first_name" AS t0_r10,
 "users"."last_name" AS t0_r11,
 "users"."created_at" AS t0_r12,
 "users"."updated_at" AS t0_r13,
 "users"."organization_id" AS t0_r14,
 "users"."authentication_token" AS t0_r15,
 "users"."invitation_token" AS t0_r16,
 "users"."invitation_created_at" AS t0_r17,
 "users"."invitation_sent_at" AS t0_r18,
 "users"."invitation_accepted_at" AS t0_r19,
 "users"."invitation_limit" AS t0_r20,
 "users"."invited_by_type" AS t0_r21,
 "users"."invited_by_id" AS t0_r22,
 "users"."invitations_count" AS t0_r23,
 "users"."manager_id" AS t0_r24,
 "users"."organization_admin" AS t0_r25,
 "users"."avatar_color" AS t0_r26,
 "users"."job_title" AS t0_r27,
 "users"."work_start_date" AS t0_r28,
 "users"."is_active" AS t0_r29,
 "users"."locale" AS t0_r30,
 "users"."elevo_admin" AS t0_r31,
 "users"."registration_number" AS t0_r32,
 "users"."management_chain" AS t0_r33,
 "users"."deactivated_at" AS t0_r34,
 "users"."external" AS t0_r35,
 "users"."external_id" AS t0_r36,
 "users"."level" AS t0_r37,
 "users"."department" AS t0_r38,
 "users"."service" AS t0_r39,
 "users"."region" AS t0_r40,
 "users"."entity_id" AS t0_r41,
 "users"."first_sign_in_at" AS t0_r42,
 "users"."use_sso" AS t0_r43,
 "users"."avatar_url" AS t0_r44,
 "users"."direct_reports_count" AS t0_r45,
 "users"."failed_attempts" AS t0_r46,
 "users"."locked_at" AS t0_r47,
 "organizations"."id" AS t1_r0,
 "organizations"."name" AS t1_r1,
 "organizations"."short_name" AS t1_r2,
 "organizations"."created_at" AS t1_r3,
 "organizations"."updated_at" AS t1_r4,
 "organizations"."locale" AS t1_r5,
 "organizations"."custom_style" AS t1_r6,
 "organizations"."demo" AS t1_r7,
 "organizations"."stripe_id" AS t1_r8,
 "organizations"."disabled" AS t1_r9,
 "organizations"."disabled_message" AS t1_r10,
 "organizations"."disabled_at" AS t1_r11,
 "managers_users"."id" AS t2_r0,
 "managers_users"."email" AS t2_r1,
 "managers_users"."encrypted_password" AS t2_r2,
 "managers_users"."reset_password_token" AS t2_r3,
 "managers_users"."reset_password_sent_at" AS t2_r4,
 "managers_users"."last_sign_in_at" AS t2_r5,
 "managers_users"."confirmation_token" AS t2_r6,
 "managers_users"."confirmed_at" AS t2_r7,
 "managers_users"."confirmation_sent_at" AS t2_r8,
 "managers_users"."unconfirmed_email" AS t2_r9,
 "managers_users"."first_name" AS t2_r10,
 "managers_users"."last_name" AS t2_r11,
 "managers_users"."created_at" AS t2_r12,
 "managers_users"."updated_at" AS t2_r13,
 "managers_users"."organization_id" AS t2_r14,
 "managers_users"."authentication_token" AS t2_r15,
 "managers_users"."invitation_token" AS t2_r16,
 "managers_users"."invitation_created_at" AS t2_r17,
 "managers_users"."invitation_sent_at" AS t2_r18,
 "managers_users"."invitation_accepted_at" AS t2_r19,
 "managers_users"."invitation_limit" AS t2_r20,
 "managers_users"."invited_by_type" AS t2_r21,
 "managers_users"."invited_by_id" AS t2_r22,
 "managers_users"."invitations_count" AS t2_r23,
 "managers_users"."manager_id" AS t2_r24,
 "managers_users"."organization_admin" AS t2_r25,
 "managers_users"."avatar_color" AS t2_r26,
 "managers_users"."job_title" AS t2_r27,
 "managers_users"."work_start_date" AS t2_r28,
 "managers_users"."is_active" AS t2_r29,
 "managers_users"."locale" AS t2_r30,
 "managers_users"."elevo_admin" AS t2_r31,
 "managers_users"."registration_number" AS t2_r32,
 "managers_users"."management_chain" AS t2_r33,
 "managers_users"."deactivated_at" AS t2_r34,
 "managers_users"."external" AS t2_r35,
 "managers_users"."external_id" AS t2_r36,
 "managers_users"."level" AS t2_r37,
 "managers_users"."department" AS t2_r38,
 "managers_users"."service" AS t2_r39,
 "managers_users"."region" AS t2_r40,
 "managers_users"."entity_id" AS t2_r41,
 "managers_users"."first_sign_in_at" AS t2_r42,
 "managers_users"."use_sso" AS t2_r43,
 "managers_users"."avatar_url" AS t2_r44,
 "managers_users"."direct_reports_count" AS t2_r45,
 "managers_users"."failed_attempts" AS t2_r46,
 "managers_users"."locked_at" AS t2_r47,
 "entities"."id" AS t3_r0,
 "entities"."created_at" AS t3_r1,
 "entities"."updated_at" AS t3_r2,
 "entities"."name" AS t3_r3,
 "entities"."organization_id" AS t3_r4,
 "entities"."users_count" AS t3_r5,
 "active_storage_attachments"."id" AS t4_r0,
 "active_storage_attachments"."name" AS t4_r1,
 "active_storage_attachments"."record_type" AS t4_r2,
 "active_storage_attachments"."record_id" AS t4_r3,
 "active_storage_attachments"."blob_id" AS t4_r4,
 "active_storage_attachments"."created_at" AS t4_r5,
 "active_storage_blobs"."id" AS t5_r0,
 "active_storage_blobs"."key" AS t5_r1,
 "active_storage_blobs"."filename" AS t5_r2,
 "active_storage_blobs"."content_type" AS t5_r3,
 "active_storage_blobs"."metadata" AS t5_r4,
 "active_storage_blobs"."byte_size" AS t5_r5,
 "active_storage_blobs"."checksum" AS t5_r6,
 "active_storage_blobs"."created_at" AS t5_r7,
 "active_storage_blobs"."service_name" AS t5_r8
 
FROM "users"

LEFT OUTER JOIN "organizations" ON "organizations"."id" = "users"."organization_id"
LEFT OUTER JOIN "users" "managers_users" ON "managers_users"."id" = "users"."manager_id"
LEFT OUTER JOIN "entities" ON "entities"."id" = "users"."entity_id"
LEFT OUTER JOIN "active_storage_attachments" ON "active_storage_attachments"."record_type" = 'User' AND "active_storage_attachments"."name" = 'avatar' AND "active_storage_attachments"."record_id" = "users"."id"
LEFT OUTER JOIN "active_storage_blobs" ON "active_storage_blobs"."id" = "active_storage_attachments"."blob_id"

WHERE (LOWER("users"."email") LIKE '%bertrand.venet%' 
OR LOWER("users"."encrypted_password") LIKE '%bertrand.venet%' 
OR LOWER("users"."reset_password_token") LIKE '%bertrand.venet%' 
OR LOWER("users"."confirmation_token") LIKE '%bertrand.venet%' 
OR LOWER("users"."unconfirmed_email") LIKE '%bertrand.venet%' 
OR LOWER("users"."first_name") LIKE '%bertrand.venet%' 
OR LOWER("users"."last_name") LIKE '%bertrand.venet%' 
OR LOWER("users"."authentication_token") LIKE '%bertrand.venet%' 
OR LOWER("users"."invitation_token") LIKE '%bertrand.venet%' 
OR LOWER("users"."invited_by_type") LIKE '%bertrand.venet%' 
OR LOWER("users"."avatar_color") LIKE '%bertrand.venet%' 
OR LOWER("users"."job_title") LIKE '%bertrand.venet%' 
OR LOWER("users"."locale") LIKE '%bertrand.venet%' 
OR LOWER("users"."registration_number") LIKE '%bertrand.venet%' 
OR LOWER("users"."management_chain") LIKE '%bertrand.venet%' 
OR LOWER("users"."external_id") LIKE '%bertrand.venet%' 
OR LOWER("users"."level") LIKE '%bertrand.venet%' 
OR LOWER("users"."department") LIKE '%bertrand.venet%' 
OR LOWER("users"."service") LIKE '%bertrand.venet%' 
OR LOWER("users"."region") LIKE '%bertrand.venet%' 
OR LOWER("users"."avatar_url") LIKE '%bertrand.venet%') 
ORDER BY "users"."created_at" DESC LIMIT 10 OFFSET 0;

We have in the organization a user with the email “bertrand.venet@gmail.com”. When I run this on a SQL console, I indeed get 1 result:

And the front-end seems to get the result too:

But it still shows “No results found”.

Hope this helps @anon39940173 :slight_smile:

Finally I am reproducing the bug on my test setup!
Thanks for taking the time (and bearing with my late replies).

I identified the commit causing the issue, and I’m filling another bug report.
As you were saying from the beginning, this is a regression from a release dated August 23rd (which by the way also caused your previous ticket here).

It should be fixed by next week (and we’ll update the thread to notify you when it’s done).

In the meantime, you may want to change the “reference field” for the users collection to “email”.
This won’t solve the issue, but at least your CS team should be able to work.

Thanks @anon39940173 :smiley:

We will do that, waiting for the fix.

Regards!

@Asmoddym

A fix was released on sept 20th.
Hope everything is now working as expected on your end

Regards

2 Likes