fix: migrate Firebase Admin SDK to v14 modular API (Service Account JSON connection fix) - #15
Merged
Merged
Conversation
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.
…ocument deletion handlers
…nto feat/show-collections
…nto feat/show-collections
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 iterableCannot read properties of undefined (reading 'cert')Root cause:
firebase-adminwas upgraded to14.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()(fromfirebase-admin/firestore)admin.auth()->getAuth()(fromfirebase-admin/auth)admin.storage()->getStorage()(fromfirebase-admin/storage)appInstance.delete()->adminSdk.deleteApp(appInstance)adminRef.firestore.FieldValue / Filter / Timestamp / GeoPoint-> top-level imports fromfirebase-admin/firestoreUnit test mocks were also updated to reflect the v14 API.
Verification
Files changed