Skip to content

fix(schematics): read the signed-in Firebase account on firebase-tools 15.26+ - #3769

Open
armando-navarro wants to merge 1 commit into
angular:mainfrom
armando-navarro:a58-login-undefined
Open

armando-navarro wants to merge 1 commit into
angular:mainfrom
armando-navarro:a58-login-undefined

Conversation

@armando-navarro

Copy link
Copy Markdown
Collaborator

Fixes #3768

firebase-tools 15.26 switches to non-interactive mode when it detects an AI agent, and in that mode login() returns undefined instead of the signed-in account. ng add and ng deploy read .email from that result and crash.

Changes

  • A new getActiveAccount helper in src/schematics/firebaseTools.ts passes interactive: true to login(). With an account signed in, login() returns it before any prompt, on firebase-tools 14 and 15.
  • Setup reads the active account through that helper in both places it needs it.
    • It no longer passes its own options to login(). Those options carry the Angular project name, which firebase-tools checks as a Firebase project ID, so a project named myApp stopped setup with Invalid project id: myApp. on any firebase-tools version.
  • The firebase login and firebase login:add commands setup starts get --interactive, so under an agent they sign the person in instead of printing remote sign-in steps.
  • When firebase login leaves no account signed in, setup says to run firebase login instead of crashing.
  • ng deploy signs in only when no account is listed, stops with the same kind of message if none is afterward, and reads the account through the helper.
  • login() is typed as possibly undefined, so the compiler flags an unguarded .email read.
  • The Quickstart and the firebase-tools install page stop saying to install firebase-tools 14. They say to run ng add yourself rather than through an AI agent, and to run it again if it already stopped.

Verification

  • ng add setup against a real Firebase project reached the account, project and app questions with:
    • firebase-tools 15.28.1 with AI_AGENT and CLAUDECODE set, which crashed before this change
    • firebase-tools 15.28.1 without them
    • firebase-tools 14.27.0
  • With --project=myApp, setup now gets past the account question, where it previously stopped with Invalid project id: myApp.
  • With what ng add @angular/fire@next installs today (21.0.0-rc.1-canary.95b3de1, built from the same commit as 21.0.0-rc.1), after a run that crashed under an agent, running ng add again without the agent variables completed setup. The crashed run left only an empty firebase.json.
  • Three new ng deploy specs cover the interactive flag, an undefined result for a signed-in account, and the no-account message. npm run test:node after a full build: 334 specs, 0 failures.
  • userPrompt has no spec, because the spec runner loads files as ES modules and prompts.ts calls require() when it loads.

firebase-tools 15.26 runs non-interactively when it detects an AI
agent or when stdin is not a terminal, and in that mode login()
returns undefined instead of the signed-in account. `ng add` and
`ng deploy` crashed reading `.email` from it.

getActiveAccount passes `interactive: true`, which returns the account
without a prompt once one is signed in. The `firebase login` and
`firebase login:add` commands setup starts get `--interactive` for the
same reason. Setup no longer passes its options to login(), since they
carry the Angular project name, which firebase-tools rejects as a
project id for names like `myApp`.

The Quickstart stops telling readers to install firebase-tools 14.

Fixes angular#3768
@armando-navarro armando-navarro added bump: patch comp: docs Documentation. comp: schematics ng add / deploy schematics (src/schematics). type: bug Defect: expected behavior doesn't happen. labels Sep 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bump: patch comp: docs Documentation. comp: schematics ng add / deploy schematics (src/schematics). type: bug Defect: expected behavior doesn't happen.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant