Unable to Find Users by Email Due to Invisible Unicode Characters in Email Address

Problem statement

Unable to search for a user by email address via the /api/v2/users-by-email or /api/v2/users endpoints or the admin portal. However, the user does return when searching by username or user_id fields via the /api/v2/users endpoint.

Symptoms

The user cannot be found by email address, either in tenant management dashboard (User Management > Users) or via management API (/api/v2/users-by-email or /api/v2/users endpoints). The user can be found by user_id in tenant management dashboard (User Management > Users) or via management API (/api/v2/users/{user_id} endpoint).

Cause

The email address contains invisible unicode characters (e.g. \u2060, WORD JOINER, A zero width non-breaking space). These invisible character are not supposed to be displayed, just like their names suggests. Although they look the same, searching email address without the invisible character doesn’t match with the actual email address, as a result, the user search by email doesn’t return any results.

1

Solution

Do not create users with invisible unicode characters. Search users by user_id, username, nickname, phone number, or any other fields that do not contain invisible characters.

Follow the steps below to identify if there are invisible unicode characters in the user’s email or any other fields in the profile. There are a few ways to identify the invisible unicode characters in the email address.

First, find the user by user_id (or username, nickname, phone number, or any other field that does not contain an invisible character).

  1. Select the Raw JSON tab.
  2. Click COPY JSON button to copy the user profile in JSON format.

Second, use any of the following tools to check if there are invisible unicode characters in the user profile:

  • VS Code highlights the invisible unicode characters by default.
// Controls whether characters that just reserve space or have no width at all are highlighted.
  "editor.unicodeHighlight.invisibleCharacters": true,