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

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

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

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions