Skip to content

fix: migrate Firebase Admin SDK to v14 modular API (Service Account JSON connection fix) - #15

Merged
flowdeskadmin merged 11 commits into
Flowdesktech:masterfrom
EMTumariscal:fix/auth-json
Aug 31, 2026
Merged

fix: migrate Firebase Admin SDK to v14 modular API (Service Account JSON connection fix)#15
flowdeskadmin merged 11 commits into
Flowdesktech:masterfrom
EMTumariscal:fix/auth-json

Conversation

@EMTumariscal

@EMTumariscal EMTumariscal commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes a critical failure that prevented connecting a Firebase project via a service account (Service Account JSON) in the "Add Firebase Project" dialog, "Service Account" tab.

When attempting to connect, the app threw the following errors in sequence:

  • adminSdk.apps is not iterable
  • Cannot read properties of undefined (reading 'cert')

Root cause: firebase-admin was upgraded to 14.3.0, which removed the entire namespace API (admin.apps, admin.credential.cert, admin.firestore(), admin.auth(), admin.storage(), app.delete()). The Electron main process still used the legacy API, so the connection failed before the JSON file was even validated.

Changes

Migrated from the namespace API to the v14 modular API across all main-process controllers:

  • adminSdk.apps -> adminSdk.getApps()
  • adminSdk.credential.cert(serviceAccount) -> adminSdk.cert(serviceAccount)
  • admin.firestore() -> getFirestore() (from firebase-admin/firestore)
  • admin.auth() -> getAuth() (from firebase-admin/auth)
  • admin.storage() -> getStorage() (from firebase-admin/storage)
  • appInstance.delete() -> adminSdk.deleteApp(appInstance)
  • adminRef.firestore.FieldValue / Filter / Timestamp / GeoPoint -> top-level imports from firebase-admin/firestore

Unit test mocks were also updated to reflect the v14 API.

Verification

  • Service Account JSON connection works again (direct fix for "Add Firebase Project" -> "Service Account" tab).
  • Firebase Emulator and Google OAuth paths remain compatible.
  • Tests: 87/87 passing. Lint, prettier, and typecheck run in the pre-commit hook.

Files changed

  • electron/controllers/firebaseController.js
  • electron/controllers/authController.js
  • electron/controllers/storageController.js
  • electron/controllers/storage/bucketResolver.js
  • electron/controllers/firestoreController.js
  • electron/controllers/index.js
  • Corresponding controller tests

doc.data() decodes referenceValue fields into DocumentReference
instances that carry the whole Firestore client, which Electron
structured clone rejects with 'An object could not be cloned' in
firestore:getDocuments and firestore:executeJsQuery handlers.

Decode documents through parseFirestoreDocument(doc._fieldsProto) so
references, timestamps and geopoints arrive as plain cloneable values,
matching the googleController REST path. Applies to getDocument, query,
exportCollection, exportCollections, executeJsQuery and the phantom-doc
page loader. Adds a regression test covering reference fields.
The admin SDK exposes timestampValue in _fieldsProto as a
{ seconds, nanos } object from the gRPC binary proto, not the RFC3339
string used by the REST JSON path. Treating the object as a Date made
_seconds NaN, crashing document rendering with 'RangeError: Invalid
time value' in formatDisplayValue.

Handle both shapes so timestamps decode to valid { _seconds,
_nanoseconds } regardless of the source API.
Replace removed namespace API (admin.apps, admin.credential.cert,
admin.firestore/auth/storage, app.delete) with v14 modular functions
(getApps, cert, getFirestore/getAuth/getStorage, deleteApp).
@EMTumariscal EMTumariscal changed the title fix: migracion a la API modular de Firebase Admin SDK v14 (conexion Service Account) fix: migrate Firebase Admin SDK to v14 modular API (Service Account JSON connection fix) Aug 31, 2026

@flowdeskadmin flowdeskadmin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

👍

@flowdeskadmin
flowdeskadmin merged commit 42e3898 into Flowdesktech:master Aug 31, 2026
1 check passed
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.

2 participants