Skip to content

ng add @angular/fire stops with Cannot read properties of undefined (reading 'email') when firebase-tools 15.26+ detects an AI agent #3768

Closed

Description

@armando-navarro

ng add @angular/fire stops during setup when firebase-tools 15.26.0 or later runs non-interactively. Running ng add yourself in an ordinary terminal is not affected.

Reproduction

In an Angular 21 application with firebase-tools 15.28.1, run ng add @angular/fire@next from a terminal where AI_AGENT or CLAUDECODE is set, for example one driven by Claude Code, and pick any feature. Setup prints:

Using firebase-tools version 15.28.1
Cannot read properties of undefined (reading 'email')

The same run with those variables unset reaches the account, project and app questions.

Cause

firebase-tools 15.26.0 turns on non-interactive mode when it detects an AI agent (firebase/firebase-tools#10856). In that mode login() now starts a remote sign-in and returns undefined instead of the signed-in account (firebase/firebase-tools#10777). Earlier versions threw an error in that mode instead.

  • userPrompt in src/schematics/setup/prompts.ts:110 reads defaultUser.email from that return value, which is the error above.
  • src/schematics/setup/index.ts:94 gets undefined the same way. With line 110 fixed alone, setup then calls login.use for an account that is already in use, which fails with Already using account ... for this project directory.
  • ng deploy reads user.email from login() in src/schematics/deploy/actions.ts:560.

Who is affected

firebase-tools runs non-interactively when stdin is not a terminal, or when it finds one of a list of variables, such as AI_AGENT, CLAUDECODE, CURSOR_AGENT or COPILOT_GITHUB_TOKEN, in the environment.

  • An AI coding tool that runs ng add or ng deploy for you.
  • A terminal that inherited one of those variables, for example an editor started from inside an agent session, or a shell profile that exports COPILOT_GITHUB_TOKEN for the Copilot CLI.
  • Every published AngularFire release has the crashing code, including latest (20.1.0) and next (21.0.0-rc.1).
  • Current Cursor (3.22.7) and VS Code (1.138.0) set them only in the terminals their agents use, not in the terminals you type in.
  • firebase-tools 15.25.1 and earlier, including 14.x, return the account in a terminal.

Directions for a fix

login() returns the signed-in account in agent mode when it is passed interactive: true, an option firebase-tools applies after its agent check. Where no account may be signed in yet, an undefined return should mean "no account" rather than be read from.

Activity

  1. changed the title [-]`ng add @angular/fire` stops with `Cannot read properties of undefined (reading 'email')` on firebase-tools 15[/-] [+]`ng add @angular/fire` stops with `Cannot read properties of undefined (reading 'email')` when firebase-tools 15.26+ detects an AI agent[/+] on Sep 25, 2026
  2. armando-navarro commented on Sep 25, 2026

    @armando-navarro
    CollaboratorAuthor

    I've corrected the title and description. My first reproduction ran inside an AI coding tool, and firebase-tools 15.26 and later treat that as non-interactive. Run in an ordinary terminal, ng add works with firebase-tools 15. The docs added in #3765 still say to install version 14, and the PR that fixes this corrects them.

  3. added a commit that references this issue on Sep 27, 2026
    38dfc3f
  4. added this to the 21.0.0-rc.2 milestone on Oct 1, 2026
  5. added a commit that references this issue on Oct 10, 2026
    490b68c
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

    comp: schematicsng add / deploy schematics (src/schematics).type: bugDefect: expected behavior doesn't happen.version: current (v17+)Targets the current modular API (v17+).

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions