Skip to content

fix issue where auth emulator had invalid type for metadata.creation_time and metadata.last_sign_in_time#9810

Merged
aalej merged 3 commits intomainfrom
aalej_fix-8109
Jan 29, 2026
Merged

fix issue where auth emulator had invalid type for metadata.creation_time and metadata.last_sign_in_time#9810
aalej merged 3 commits intomainfrom
aalej_fix-8109

Conversation

@aalej
Copy link
Copy Markdown
Contributor

@aalej aalej commented Jan 26, 2026

Description

Fixes #8109.

It seems like the expected type for user_record.metadata.creation_time and user_record.metadata.last_sign_in_time is number, since if they are sent to the functions emulator as a string, they can't be parsed https://github.com/firebase/firebase-functions/blob/5f7b331abd5a2a38a4e84de1e51411ea5919c0c3/src/common/providers/identity.ts#L554-L564

code below will result in Invalid Date

const creationTime = new Date("1769443209763").toUTCString()
console.log(creationTime) // Invalid Date

but numbers will work

const creationTime = new Date(1769443209763).toUTCString()
console.log(creationTime) // Mon, 26 Jan 2026 16:00:09 GMT

Seems like both firebase-functions and firebase-admin expect creation_time and last_sign_in_time to be numbers

Scenarios Tested

See https://github.com/aalej/issues-8109_PR for a repro

Using the mcve:

  1. Run firebase emulators:start --project demo-project
  2. Go to "127.0.0.1:5000"
  3. Add an email and password
  4. Click "Create User" button
  5. Check terminal logs where the emulator is running
{
  "providerData": [
    { "uid": "foo@bar.com", "email": "foo@bar.com", "providerId": "password" }
  ],
  "providerId": "password",
  "isNewUser": false,
  "metadata": {
    "creationTime": "Mon, 26 Jan 2026 17:15:21 GMT",
    "lastSignInTime": "Mon, 26 Jan 2026 17:15:21 GMT"
  }
}

matched with prod console logs
image

Sample Commands

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @aalej, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical data type mismatch in the Firebase Auth Emulator. Previously, user metadata timestamps (creation_time and last_sign_in_time) were incorrectly provided as strings, leading to parsing failures in dependent Firebase services like Functions and Admin SDK. The changes ensure these timestamps are consistently represented as numbers, resolving compatibility issues and improving the reliability of user authentication events.

Highlights

  • Data Type Correction: The metadata.creation_time and metadata.last_sign_in_time fields within the Auth Emulator's AuthBlockingEvent JWT payload are now correctly typed as number (timestamps in milliseconds) instead of string.
  • Timestamp Parsing: Implemented parseInt() calls to convert string-based timestamps (user.lastLoginAt, user.createdAt) into numerical values before they are included in the JWT payload.
  • Type Definition Update: The BlockingFunctionsJwtPayload TypeScript interface has been updated to reflect the correct number type for last_sign_in_time and creation_time metadata fields.
  • Test Suite Alignment: Existing test cases in emailLink.spec.ts were updated to assert that creation_time is a number, aligning tests with the corrected data type.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The pull request effectively addresses the issue where metadata.creation_time and metadata.last_sign_in_time were incorrectly formatted as strings instead of numbers in the Auth emulator's JWT payload. The changes correctly update the BlockingFunctionsJwtPayload type definition and ensure that these timestamp fields are parsed to numbers before being included in the JWT. The corresponding test assertions have also been updated to reflect this change, ensuring the emulator's behavior aligns with the expectations of firebase-functions and firebase-admin.

@joehan joehan requested a review from yuchenshi January 27, 2026 18:47
@aalej aalej enabled auto-merge (squash) January 29, 2026 11:26
@aalej aalej merged commit 750ef35 into main Jan 29, 2026
47 checks passed
@aalej aalej deleted the aalej_fix-8109 branch January 29, 2026 11:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing details in the AuthBlockingEvent when using with the Authentication Emulator

3 participants