Skip to content

admin.auth().getUserByEmail is case-insensitive against live data, but case-sensitive against emulator data #8344

Closed

Description

@djak250

[REQUIRED] Environment info

firebase-tools: 13.34.0

Platform: macOs

[REQUIRED] Test case

Environment setup

  1. Start up just the auth emulator and export emulator host
firebase emulators:start --only auth --project demo-project
  1. Create a user in the emulator AND live environment with the same email: [email protected]

fetchUserByEmail.js

const admin = require('firebase-admin');
admin.initializeApp();

(async () => {
  try {
    const matchingCase = '[email protected]';
    const user = await admin.auth().getUserByEmail(matchingCase);
    console.log(user); // Logs
  } catch (e) {
    console.error(e); // Doesn't Log
  }
  try {
    const nonMatchingCase = '[email protected]';
    const user = await admin.auth().getUserByEmail(nonMatchingCase); // Throws auth/user-not-found
    console.log(user); // Doesn't Log
  } catch (e) {
    console.error(e); // Logs user not found error
  }
  await admin.app().delete();
})();

[REQUIRED] Steps to reproduce

  • Run script against emulator:
FIREBASE_AUTH_EMULATOR_HOST=127.0.0.1:9099 \
GCLOUD_PROJECT_ID=demo-project \
node ./fetchUserByEmail.js
  • Run script against live data:
GCLOUD_PROJECT_ID=project-live \
node ./fetchUserByEmail.js

[REQUIRED] Expected behavior

The user is found in both environments, regardless of email casing.

[REQUIRED] Actual behavior

The user is found in the live environment, regardless of email casing.
The user is found in the emulator environment when the casing matches,
but throws an auth/user-not-found error when casing does not match.

Activity

  1. aalej commented on Mar 21, 2025

    @aalej
    Contributor

    Thanks for the report @djak250! It does look like this is a bug in the Auth emulator since it does not match the behavior in production. I'll mark this as reproducible and discuss it with our engineering team.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions