firebase-admin
>=11.0.0 <15.0.0postconditions118functions54last verified2026-06-25coverage score60%Postconditions: what we check
- verifyIdToken · token-expirederrorWhenID token has expiredThrows
FirebaseAuthError with code 'auth/id-token-expired'Required handlingCaller MUST catch and handle expired token errors. Return 401 Unauthorized to client and require re-authentication. DO NOT retry with same token - it's permanently expired.costhighin prodimmediate exceptionusers seelost datavisibilityvisibleSources[1] - verifyIdToken · token-invaliderrorWhenID token is invalid (malformed, wrong project, revoked)Throws
FirebaseAuthError with code 'auth/argument-error' or 'auth/id-token-revoked'Required handlingCaller MUST validate token format and handle invalid tokens. Check error.code to distinguish between format errors and revoked tokens. Return 401 Unauthorized to client.costhighin prodimmediate exceptionusers seelost datavisibilityvisibleSources[2] - verifyIdToken · network-errorerrorWhenNetwork request to Firebase Auth service failedThrows
FirebaseAuthError or generic ErrorRequired handlingCaller SHOULD implement retry with exponential backoff for transient failures. Check if Firebase Auth service is available.costhighin prodimmediate exceptionusers seelost datavisibilityvisibleSources[3] - createUser · email-already-existserrorWhenEmail address is already in useThrows
FirebaseAuthError with code 'auth/email-already-exists'Required handlingCaller MUST check if error.code === 'auth/email-already-exists'. Return user-friendly error message. Consider suggesting password reset if user forgot they have an account. DO NOT retry with same email.costhighin prodimmediate exceptionusers seelost datavisibilityvisibleSources[1] - createUser · invalid-emailerrorWhenEmail format is invalidThrows
FirebaseAuthError with code 'auth/invalid-email'Required handlingCaller SHOULD validate email format before calling createUser. Use email validation library to prevent this error.costhighin prodimmediate exceptionusers seelost datavisibilityvisibleSources[1] - createUser · uid-already-existserrorWhenProvided UID is already in use (when specifying custom UID)Throws
FirebaseAuthError with code 'auth/uid-already-exists'Required handlingIf using custom UIDs, generate unique values. Catch this error and either generate new UID or handle collision.costhighin prodimmediate exceptionusers seelost datavisibilityvisibleSources[1] - createUser · invalid-passworderrorWhenPassword is too weak or doesn't meet requirementsThrows
FirebaseAuthError with code 'auth/invalid-password'Required handlingValidate password strength on client side. Firebase requires minimum 6 characters. Return helpful error to user about password requirements.costhighin prodimmediate exceptionusers seelost datavisibilityvisibleSources[4] - getUser · user-not-founderrorWhenNo user record found for the given UIDThrows
FirebaseAuthError with code 'auth/user-not-found'Required handlingCaller MUST handle user-not-found errors. DO NOT assume user exists - always catch this error. Consider if this indicates deleted account or invalid UID.costhighin prodimmediate exceptionusers seelost datavisibilityvisibleSources[1] - getUser · invalid-uiderrorWhenUID format is invalidThrows
FirebaseAuthError with code 'auth/invalid-uid'Required handlingValidate UID format before calling getUser. Firebase UIDs are typically 28-character strings.costhighin prodimmediate exceptionusers seelost datavisibilityvisibleSources[1] - updateUser · user-not-founderrorWhenNo user record found for the given UIDThrows
FirebaseAuthError with code 'auth/user-not-found'Required handlingCaller MUST handle user-not-found errors. Decide whether to create user or return error.costhighin prodimmediate exceptionusers seelost datavisibilityvisibleSources[1] - updateUser · email-already-existserrorWhenNew email address is already in use by another userThrows
FirebaseAuthError with code 'auth/email-already-exists'Required handlingCheck if new email is available before updating. Return user-friendly error if email is taken.costhighin prodimmediate exceptionusers seelost datavisibilityvisibleSources[1] - deleteUser · user-not-founderrorWhenNo user record found for the given UIDThrows
FirebaseAuthError with code 'auth/user-not-found'Required handlingCaller SHOULD handle user-not-found errors gracefully. Consider if idempotent delete is acceptable (user already deleted).costhighin prodimmediate exceptionusers seelost datavisibilityvisibleSources[1] - getUserByEmail · user-not-founderrorWhenNo user record with the given emailThrows
FirebaseAuthError with code 'auth/user-not-found'Required handlingCaller MUST handle user-not-found errors. This is common when checking if email is registered.costhighin prodimmediate exceptionusers seelost datavisibilityvisibleSources[1] - setCustomUserClaims · user-not-founderrorWhenNo user record foundThrows
FirebaseAuthError with code 'auth/user-not-found'Required handlingVerify user exists before setting claims.costhighin prodimmediate exceptionusers seelost datavisibilityvisibleSources[1] - setCustomUserClaims · invalid-claimserrorWhenClaims object exceeds 1000 bytes or uses reserved keysThrows
FirebaseAuthError with code 'auth/invalid-claims'Required handlingValidate claims size and avoid reserved keys. Reserved keys: iss, sub, aud, exp, iat, auth_time, nonce, etc.costhighin prodimmediate exceptionusers seelost datavisibilityvisibleSources[5] - get · permission-deniederrorWhenSecurity rules deny read accessThrows
Error with code 'PERMISSION_DENIED' (gRPC code 7)Required handlingCaller MUST handle permission errors. Check Firestore security rules. Admin SDK bypasses rules by default - if seeing this, check service account permissions.costhighin prodimmediate exceptionusers seelost datavisibilityvisibleSources[6] - get · not-founderrorWhenDocument does not existReturnsDocumentSnapshot with exists: falseRequired handlingCaller MUST check snapshot.exists before accessing data. Use snapshot.exists or check if snapshot.data() is undefined.costhighin prodimmediate exceptionusers seelost datavisibilityvisibleSources[7]
- get · deadline-exceedederrorWhenOperation timed outThrows
Error with code 'DEADLINE_EXCEEDED' (gRPC code 4)Required handlingCaller SHOULD implement retry with exponential backoff. Check network connectivity and Firestore status. Consider if query is too complex (missing indexes).costhighin prodimmediate exceptionusers seelost datavisibilityvisibleSources[6] - add · permission-deniederrorWhenSecurity rules deny write accessThrows
Error with code 'PERMISSION_DENIED' (gRPC code 7)Required handlingCheck Firestore security rules and service account permissions.costhighin prodimmediate exceptionusers seelost datavisibilityvisibleSources[6] - add · resource-exhaustederrorWhenWrite quota exceeded or rate limit hitThrows
Error with code 'RESOURCE_EXHAUSTED' (gRPC code 8)Required handlingCaller MUST handle quota errors. Check if billing is enabled (free tier limits). Implement backoff and reduce write rate. Avoid writing to lexicographically close documents (hot spots).costhighin prodimmediate exceptionusers seelost datavisibilityvisibleSources[8] - set · abortederrorWhenTransaction aborted due to contentionThrows
Error with code 'ABORTED' (gRPC code 10)Required handlingCaller SHOULD retry with exponential backoff and jitter. Occurs when multiple transactions access same data. Consider redesigning to reduce contention.costhighin prodimmediate exceptionusers seelost datavisibilityvisibleSources[6] - set · resource-exhaustederrorWhenWrite quota exceededThrows
Error with code 'RESOURCE_EXHAUSTED'Required handlingImplement rate limiting and backoff. Check daily write quota and billing status.costhighin prodimmediate exceptionusers seelost datavisibilityvisibleSources[8] - update · not-founderrorWhenDocument to update does not existThrows
Error with code 'NOT_FOUND' (gRPC code 5)Required handlingCaller MUST handle not-found errors. Use set() with merge: true if you want to create-or-update. update() requires document to exist.costhighin prodimmediate exceptionusers seelost datavisibilityvisibleSources[9] - update · abortederrorWhenTransaction contentionThrows
Error with code 'ABORTED'Required handlingRetry with exponential backoff.costhighin prodimmediate exceptionusers seelost datavisibilityvisibleSources[6] - delete · permission-deniederrorWhenSecurity rules deny delete accessThrows
Error with code 'PERMISSION_DENIED'Required handlingCheck security rules and permissions.costhighin prodimmediate exceptionusers seelost datavisibilityvisibleSources[6] - send · invalid-recipienterrorWhenDevice token is invalid, expired, or unregisteredThrows
FirebaseMessagingError with code 'messaging/invalid-recipient'Required handlingCaller MUST remove invalid tokens from database. Check error code and error.code === 'messaging/invalid-recipient'. Tokens can expire if user uninstalls app or revokes permissions.costhighin prodimmediate exceptionusers seelost datavisibilityvisibleSources[10] - send · invalid-argumenterrorWhenMessage payload is malformed or exceeds size limitsThrows
FirebaseMessagingError with code 'messaging/invalid-argument'Required handlingValidate message structure before sending. Check payload size limits (4KB for data messages). Verify required fields are present.costhighin prodimmediate exceptionusers seelost datavisibilityvisibleSources[10] - send · quota-exceedederrorWhenFCM rate limit exceededThrows
FirebaseMessagingError with code 'messaging/quota-exceeded'Required handlingImplement exponential backoff retry. Reduce message send rate. Check if quota limit is reasonable for use case.costhighin prodimmediate exceptionusers seelost datavisibilityvisibleSources[10] - sendMulticast · partial-failureerrorWhenSome tokens succeeded, some failedReturnsBatchResponse with failureCount > 0Required handlingCaller MUST check response.failureCount and response.responses array. Each response contains success boolean and optional error. Remove invalid tokens from database based on specific error codes.costhighin prodimmediate exceptionusers seelost datavisibilityvisibleSources[11]
- sendMulticast · invalid-argumenterrorWhenInvalid tokens or payloadThrows
FirebaseMessagingErrorRequired handlingValidate all tokens and payload before sending.costhighin prodimmediate exceptionusers seelost datavisibilityvisibleSources[10] - sendToTopic · invalid-topicerrorWhenTopic name is invalid or doesn't existThrows
FirebaseMessagingError with code 'messaging/invalid-argument'Required handlingValidate topic name format. Topic names must match /topics/[a-zA-Z0-9-_.~%]+costhighin prodimmediate exceptionusers seelost datavisibilityvisibleSources[12] - once · permission-deniederrorWhenDatabase rules deny read accessThrows
Error with code 'PERMISSION_DENIED'Required handlingCheck Realtime Database rules. Admin SDK bypasses rules by default - if seeing this, check databaseAuthVariableOverride.costhighin prodimmediate exceptionusers seelost datavisibilityvisibleSources[13] - once · network-errorerrorWhenNetwork connection failedThrows
ErrorRequired handlingImplement retry with exponential backoff for transient failures.costhighin prodimmediate exceptionusers seelost datavisibilityvisibleSources[3] - set · permission-deniederrorWhenDatabase rules deny write accessThrows
Error with code 'PERMISSION_DENIED'Required handlingCheck database rules and authentication.costhighin prodimmediate exceptionusers seelost datavisibilityvisibleSources[14] - update · permission-deniederrorWhenDatabase rules deny write accessThrows
Error with code 'PERMISSION_DENIED'Required handlingCheck database rules.costhighin prodimmediate exceptionusers seelost datavisibilityvisibleSources[14] - remove · permission-deniederrorWhenDatabase rules deny delete accessThrows
Error with code 'PERMISSION_DENIED'Required handlingCheck database rules.costhighin prodimmediate exceptionusers seelost datavisibilityvisibleSources[14] - createSessionCookie · session-cookie-invalid-durationerrorWhenexpiresIn is not provided, not a number, or outside the allowed range (5 minutes to 2 weeks)Throws
FirebaseAuthError with code 'auth/invalid-session-cookie-duration'Required handlingValidate expiresIn is a number between 300000ms (5 min) and 1209600000ms (2 weeks) before calling. Catch this error and return 400 Bad Request with a clear message. This error rejects synchronously — no network call is made.costhighin prodimmediate exceptionusers seeauthentication failurevisibilityvisibleSources[1] - createSessionCookie · session-cookie-invalid-id-tokenerrorWhenID token is malformed, expired, or belongs to a different Firebase projectThrows
FirebaseAuthError with code 'auth/invalid-id-token'Required handlingCatch this error at the login endpoint and return 401 Unauthorized. The ID token must be recently issued (within 5 minutes). Require the front-end to obtain a fresh ID token and retry.costhighin prodimmediate exceptionusers seeauthentication failurevisibilityvisibleSources[1] - createSessionCookie · session-cookie-network-errorerrorWhenFirebase Auth service is unreachableThrows
FirebaseAuthError or network ErrorRequired handlingCatch network errors at the login endpoint and return 503 Service Unavailable. Implement exponential backoff retry for transient failures.costhighin prodimmediate exceptionusers seeauthentication failurevisibilityvisibleSources[1] - verifySessionCookie · session-cookie-expirederrorWhenSession cookie's expiry time has passedThrows
FirebaseAuthError with code 'auth/session-cookie-expired'Required handlingCatch in authentication middleware. Clear the session cookie and redirect to login. DO NOT retry — the cookie is permanently expired.costhighin prodimmediate exceptionusers seeauthentication failurevisibilityvisibleSources[1] - verifySessionCookie · session-cookie-revokederrorWhencheckRevoked=true and the user's session was revoked via revokeRefreshTokens()Throws
FirebaseAuthError with code 'auth/session-cookie-revoked'Required handlingCatch in authentication middleware alongside cookie-expired. Clear the session cookie and redirect to login. Distinguish from expired for proper UX messaging.costhighin prodimmediate exceptionusers seeauthentication failurevisibilityvisibleSources[1] - verifySessionCookie · session-cookie-invaliderrorWhenSession cookie is malformed, has invalid signature, or belongs to different Firebase projectThrows
FirebaseAuthError with code 'auth/argument-error' or similarRequired handlingCatch in authentication middleware. Return 401 Unauthorized and clear the invalid cookie. Never swallow this error — tampered cookies must be rejected.costhighin prodimmediate exceptionusers seeauthentication failurevisibilityvisibleSources[1] - verifySessionCookie · session-cookie-user-disablederrorWhencheckRevoked=true and the user account has been disabledThrows
FirebaseAuthError with code 'auth/user-disabled'Required handlingCatch separately from cookie-expired and cookie-revoked. Return a disabled-account response, not a generic 401. Requires network call to Firebase Auth.costmediumin prodimmediate exceptionusers seeauthentication failurevisibilityvisibleSources[1] - createCustomToken · custom-token-invalid-uiderrorWhenuid is empty, not a string, or exceeds 128 charactersThrows
FirebaseAuthError with code 'auth/argument-error'Required handlingValidate uid is a non-empty string of 128 chars or fewer before calling. Catch and return 400 Bad Request. This rejects synchronously before signing.costmediumin prodimmediate exceptionusers seeauthentication failurevisibilityvisibleSources[15] - createCustomToken · custom-token-invalid-claimserrorWhendeveloperClaims contains reserved JWT keys (iss, sub, aud, exp, iat, firebase, etc.)Throws
FirebaseAuthError with code 'auth/argument-error'Required handlingAvoid reserved JWT claim keys in developerClaims. Validate claims object does not contain reserved names before calling. Catch and return 400.costmediumin prodimmediate exceptionusers seeauthentication failurevisibilityvisibleSources[15] - createCustomToken · custom-token-signing-errorerrorWhenService account private key is invalid, revoked, or corruptThrows
FirebaseAuthError with code 'auth/invalid-credential'Required handlingCatch and alert on this error — it indicates service account misconfiguration. Return 500 Internal Server Error. Do not retry. Requires manual key rotation fix.costhighin prodimmediate exceptionusers seeauthentication failurevisibilityvisibleSources[15] - revokeRefreshTokens · revoke-tokens-user-not-founderrorWhenUID does not correspond to an existing Firebase userThrows
FirebaseAuthError with code 'auth/user-not-found'Required handlingCatch and treat as success — user is already gone so revocation is moot. Log the discrepancy but do not crash the security incident handler.costlowin prodimmediate exceptionusers seedegraded performancevisibilityvisibleSources[1] - revokeRefreshTokens · revoke-tokens-network-errorerrorWhenFirebase Auth service is unreachable during revocationThrows
FirebaseAuthError or network ErrorRequired handlingMUST catch and retry on network failure. Failed revocation during a security incident leaves compromised sessions active. Implement exponential backoff. Alert if retries are exhausted.costhighin prodimmediate exceptionusers seedegraded performancevisibilitysilentSources[1] - generatePasswordResetLink · password-reset-user-not-founderrorWhenNo user exists with the specified email addressThrows
FirebaseAuthError with code 'auth/email-not-found' or 'auth/user-not-found'Required handlingCatch and return success regardless to prevent email enumeration attacks. Do not reveal whether the email is registered. Log the error internally.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[1] - generatePasswordResetLink · password-reset-invalid-emailerrorWhenEmail format is invalidThrows
FirebaseAuthError with code 'auth/invalid-email'Required handlingValidate email format with a regex or Zod schema before calling. Catch and return 400 Bad Request with a user-friendly message.costlowin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[1] - runTransaction · transaction-aborted-max-retrieserrorWhenTransaction contention persists across all 5 automatic retry attemptsThrows
Error with gRPC code ABORTED (code 10) — message: 'Too much contention on these datastore entities. Please try again.'Required handlingCatch the final rejection after retries are exhausted and return a 409 Conflict or retry the full operation at the application level with backoff. Do not swallow this error — silent swallowing causes lost writes that appear as stale data.costhighin prodimmediate exceptionusers seedegraded performancevisibilitysilentSources[6] - runTransaction · transaction-deadline-exceedederrorWhenTransaction execution exceeds Firestore's 60-second server deadlineThrows
Error with gRPC code DEADLINE_EXCEEDED (code 4)Required handlingCatch and treat as a non-retryable failure — the transaction was rolled back. For background jobs, return a failure result. For API routes, return 503. Break large transactions into smaller units to avoid hitting the deadline.costhighin prodimmediate exceptionusers seelost datavisibilitysilentSources[6] - runTransaction · transaction-failed-offlineerrorWhenFirestore service is unreachable or the network connection is unavailableThrows
Error with gRPC code UNAVAILABLE (code 14)Required handlingCatch and implement external retry with exponential backoff. The Admin SDK does NOT queue offline — it fails immediately. Background jobs MUST retry externally when UNAVAILABLE errors occur during network partitions.costhighin prodimmediate exceptionusers seelost datavisibilitysilentSources[6] - runTransaction · transaction-function-side-effectswarningWhenThe transaction update function contains side effects that execute on every retry attemptThrows
No throw — side effects execute silently N times (up to 5)Required handlingKeep the updateFunction free of observable side effects beyond Firestore writes. Move external API calls, payments, and email sends to AFTER the transaction resolves.costhighin prodsilent failureusers seelost transactionvisibilitysilentSources[16] - commit · batch-resource-exhaustederrorWhenWrite quota is exceeded or batch causes a hot-spot on a documentThrows
Error with gRPC code RESOURCE_EXHAUSTED (code 8)Required handlingCatch and implement exponential backoff retry. Batch commits that hit RESOURCE_EXHAUSTED have NOT been applied — retry the full batch. Add jitter to backoff to prevent thundering herd in serverless deployments.costhighin prodimmediate exceptionusers seelost datavisibilitysilentSources[6] - commit · batch-abortederrorWhenBatch write fails due to document contentionThrows
Error with gRPC code ABORTED (code 10)Required handlingCatch ABORTED and retry the full batch from scratch. WriteBatch does NOT automatically retry unlike runTransaction(). No writes are applied on ABORTED — the batch is atomic and all-or-nothing.costhighin prodimmediate exceptionusers seelost datavisibilitysilentSources[6] - commit · batch-too-many-operationserrorWhenBatch contains more than 500 write operationsThrows
Error with gRPC INVALID_ARGUMENT — Firestore's hard 500-operation limit per batchRequired handlingSplit large datasets into chunks of 500 or fewer before committing. Validate batch size before calling commit(). The SDK throws before sending to the server — no partial writes occur.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[16] - sendEach · send-each-partial-failureerrorWhenOne or more messages fail to send while others succeed (partial failure)Throws
Promise resolves with BatchResponse where failureCount > 0; does NOT reject on partial failureRequired handlingAfter every sendEach() call, check response.failureCount. If > 0, iterate response.responses to find per-message errors. Remove tokens with 'messaging/registration-token-not-registered' from the database. failureCount === messages.length means total failure with no deliveries.costmediumin prodsilent failureusers seedegraded performancevisibilitysilentSources[11] - sendEach · send-each-rate-exceedederrorWhenGlobal FCM send rate limit is exceeded during batch sendThrows
FirebaseMessagingError with code 'messaging/message-rate-exceeded'Required handlingCatch and implement exponential backoff before retrying. This is a global rate limit (not per-device). Reduce send frequency or fan out over time. Distinguish from per-device 'messaging/device-message-rate-exceeded' errors that appear in per-message response.responses[i].error.costmediumin prodimmediate exceptionusers seedegraded performancevisibilitysilentSources[10] - sendEach · send-each-invalid-argumenterrorWhenMessage payloads are malformed, tokens are empty strings, or required fields are missingThrows
FirebaseMessagingError with code 'messaging/invalid-argument'Required handlingValidate all message objects before calling sendEach(). Ensure tokens are non-empty strings. Catch and return 400 Bad Request. Input validation before the call prevents the entire batch from being rejected.costmediumin prodimmediate exceptionusers seedegraded performancevisibilityvisibleSources[10] - subscribeToTopic · subscribe-partial-failureerrorWhenOne or more tokens fail to subscribe while others succeedThrows
Promise resolves with MessagingTopicManagementResponse where errors array is non-empty; does NOT rejectRequired handlingAfter every subscribeToTopic() call, check response.errors array. Remove tokens with 'messaging/registration-token-not-registered' from the database. Partial success means some tokens were subscribed; do not assume all succeeded when Promise resolves.costlowin prodsilent failureusers seedegraded performancevisibilitysilentSources[17] - subscribeToTopic · subscribe-invalid-topicerrorWhenTopic name is invalid — does not match /topics/[a-zA-Z0-9-_.~%]+ patternThrows
FirebaseMessagingError with code 'messaging/invalid-argument'Required handlingValidate topic names before calling. Topic names must match [a-zA-Z0-9-_.~%]+ (the /topics/ prefix is added automatically if omitted). Catch and return 400 Bad Request for invalid topic name inputs.costlowin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[17] - importUsers · import-users-batch-too-largeerrorWhenusers array contains more than 1000 recordsThrows
FirebaseAuthError with code 'auth/maximum-user-count-exceeded'Required handlingSplit user arrays into chunks of 1000 before calling importUsers(). The SDK throws synchronously before any network call. Validate batch size before calling to avoid this failure mid-migration.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[18] - importUsers · import-users-partial-failureerrorWhenOne or more individual user records fail validation or import while others succeedThrows
Promise RESOLVES with UserImportResult where failureCount > 0; does NOT reject on per-user failureRequired handlingAfter every importUsers() call, check result.failureCount. If > 0, inspect result.errors array — each entry contains index (original array position) and error (the failure reason). DO NOT assume all users were imported when the Promise resolves. Per-user failures include invalid email, duplicate UID, invalid password hash, and provider data conflicts. Log per-user errors for remediation.costhighin prodsilent failureusers seedegraded performancevisibilitysilentSources[19] - importUsers · import-users-tenant-mismatcherrorWhenUser records contain tenantId fields that don't match the TenantAwareAuth tenant contextThrows
FirebaseAuthError with code 'auth/mismatching-tenant-id'Required handlingWhen using multi-tenancy: ensure all user records in the batch have tenantId matching the TenantAwareAuth instance. Catch this error and reject the entire import batch — this is a configuration error.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[18] - generateSignInWithEmailLink · sign-in-link-missing-action-code-settingserrorWhenactionCodeSettings parameter is missing, null, or undefinedThrows
FirebaseAuthError with code 'auth/argument-error' — 'actionCodeSettings is required'Required handlingAlways pass actionCodeSettings with at least url (the deep link the user is redirected to after clicking). This error is thrown synchronously — no network call occurs. Catch and return 400 Bad Request.costlowin prodimmediate exceptionusers seeauthentication failurevisibilityvisibleSources[18] - generateSignInWithEmailLink · sign-in-link-user-not-founderrorWhenNo Firebase user exists with the given email addressThrows
FirebaseAuthError with code 'auth/email-not-found' or 'auth/user-not-found'Required handlingFor sign-in links, user-not-found may indicate the email is not registered. Catch and return success regardless to prevent email enumeration attacks. Do not reveal whether the email is registered.costlowin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[1] - generateSignInWithEmailLink · sign-in-link-network-errorerrorWhenFirebase Auth service is unreachableThrows
FirebaseAuthError or network ErrorRequired handlingCatch and retry with exponential backoff for transient failures. Return 503 to the caller if retries are exhausted.costlowin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[1] - generateVerifyAndChangeEmailLink · verify-change-email-missing-new-emailerrorWhennewEmail parameter is undefined, null, or missingThrows
FirebaseAuthError with code 'auth/argument-error' — 'newEmail is required'Required handlingAlways pass newEmail as the second argument. This error is thrown synchronously — no network call occurs. Validate both email and newEmail before calling. Catch and return 400 Bad Request.costlowin prodimmediate exceptionusers seeauthentication failurevisibilityvisibleSources[18] - generateVerifyAndChangeEmailLink · verify-change-email-invalid-emailerrorWhenCurrent email or newEmail is not a valid email formatThrows
FirebaseAuthError with code 'auth/invalid-email'Required handlingValidate both email addresses with a regex or Zod schema before calling. Catch and return 400 Bad Request with a user-friendly message.costlowin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[1] - generateVerifyAndChangeEmailLink · verify-change-email-user-not-founderrorWhenNo user exists with the given current email addressThrows
FirebaseAuthError with code 'auth/email-not-found' or 'auth/user-not-found'Required handlingCatch and handle gracefully. Avoid revealing whether email is registered in publicly accessible endpoints (email enumeration prevention).costlowin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[1] - getTemplate · remote-config-get-permission-deniederrorWhenService account lacks Remote Config Viewer or Editor roleThrows
FirebaseRemoteConfigError with code 'remote-config/permission-denied'Required handlingCatch and alert — this is a service account misconfiguration that will prevent all Remote Config reads. Return 500 to the caller. Grant the Firebase Remote Config Admin role to the service account in IAM. Do not retry — this error is not transient.costhighin prodimmediate exceptionusers seeservice unavailablevisibilitysilentSources[20] - getTemplate · remote-config-get-quota-exceededwarningWhenRemote Config REST API quota is exceeded (default: 2000 requests/day for GET)Throws
FirebaseRemoteConfigError with code 'remote-config/resource-exhausted'Required handlingCache the Remote Config template locally rather than fetching it on every request. Implement a TTL-based cache (Firebase recommends 15 minutes for most use cases). Catch this error and serve the last cached template. Do not fetch on every user request — this rapidly exhausts quota.costmediumin prodimmediate exceptionusers seedegraded performancevisibilitysilentSources[21] - getTemplate · remote-config-get-network-errorerrorWhenFirebase Remote Config service is unreachable or network failsThrows
FirebaseRemoteConfigError with code 'remote-config/unknown-error' or network ErrorRequired handlingCatch and serve last cached template if available. Implement exponential backoff retry for transient failures. Do not crash the application when Remote Config is temporarily unavailable — serve defaults instead.costmediumin prodimmediate exceptionusers seedegraded performancevisibilitysilentSources[20] - publishTemplate · remote-config-publish-etag-mismatcherrorWhenTemplate ETag does not match the current server ETag — another process published the template after getTemplate() was calledThrows
FirebaseRemoteConfigError with code 'remote-config/aborted'Required handlingCatch 'remote-config/aborted' and retry: call getTemplate() to get the latest template, reapply your changes to it, then call publishTemplate() again. This prevents overwriting concurrent changes. Using force:true bypasses the ETag but risks losing changes made by other processes.costmediumin prodimmediate exceptionusers seelost datavisibilityvisibleSources[20] - publishTemplate · remote-config-publish-invalid-templateerrorWhenTemplate has missing ETag, invalid conditions, or malformed parameter valuesThrows
FirebaseRemoteConfigError with code 'remote-config/invalid-argument'Required handlingCall validateTemplate() before publishTemplate() to catch structural errors without committing them. Catch 'invalid-argument' and log the error details — these indicate template schema violations.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[20] - publishTemplate · remote-config-publish-quota-exceedederrorWhenRemote Config write quota exceeded (default: 1 publish per second per project)Throws
FirebaseRemoteConfigError with code 'remote-config/resource-exhausted'Required handlingImplement rate limiting before publishing — only one publish per second is allowed. Catch this error and retry after a 1-second delay. Do not use publishTemplate() in hot code paths — it is an admin operation.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[21] - validateTemplate · remote-config-validate-invalid-argumenterrorWhenTemplate has missing ETag, malformed conditions, invalid parameter names, or circular referencesThrows
FirebaseRemoteConfigError with code 'remote-config/invalid-argument'Required handlingCatch and inspect the error message — the server returns specific details about what is invalid (e.g., invalid condition expression, reserved parameter name). Fix the template structure before retrying. This is the expected failure mode — validateTemplate() is specifically designed to surface these errors before they affect production.costlowin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[20] - validateTemplate · remote-config-validate-permission-deniederrorWhenService account lacks Remote Config Editor or Admin roleThrows
FirebaseRemoteConfigError with code 'remote-config/permission-denied'Required handlingCatch and alert on this error — it indicates service account misconfiguration. The service account requires Firebase Remote Config Admin role, not just Viewer. Return 500 Internal Server Error. Do not retry.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[20] - createProviderConfig · create-provider-config-invalid-provider-iderrorWhenproviderId does not start with 'saml.' or 'oidc.' prefix, or is missing from the config object entirelyThrows
FirebaseAuthError with code 'auth/invalid-provider-id'Required handlingValidate providerId format before calling createProviderConfig. OIDC provider IDs must start with 'oidc.' and SAML with 'saml.'. This is a synchronous validation error — no retry is useful. Return 400 Bad Request with clear description of required format.costlowin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[22] - createProviderConfig · create-provider-config-quota-exceedederrorWhenProject has reached the maximum number of SAML or OIDC provider configurationsThrows
FirebaseAuthError with code 'auth/quota-exceeded'Required handlingCatch and surface this as a billing/plan limit error. The project has hit the GCIP provider config limit. Do not retry — the error persists until existing configs are deleted. Return 429 or 503 with explanation to the calling service.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[23] - createProviderConfig · create-provider-config-insufficient-permissionerrorWhenService account lacks Identity Platform Admin or required IAM roleThrows
FirebaseAuthError with code 'auth/insufficient-permission'Required handlingCatch and alert — this is a service account misconfiguration. The service account requires the 'Firebase Authentication Admin' or 'identitytoolkit.admin' IAM role. Do not retry. Return 500 Internal Server Error and alert on-call.costhighin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[23] - updateProviderConfig · update-provider-config-not-founderrorWhenNo provider configuration exists for the given providerIdThrows
FirebaseAuthError with code 'auth/configuration-not-found'Required handlingCatch and handle this as a 404. The provider config was deleted or never created. Verify the providerId is correct and the config exists before updating. Do not retry with same ID — the error is permanent until the config is created.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[24] - updateProviderConfig · update-provider-config-invalid-configerrorWhenupdatedConfig is null, not an object, or contains invalid field valuesThrows
FirebaseAuthError with code 'auth/invalid-config'Required handlingValidate configuration object before calling updateProviderConfig. OIDC requires clientId, issuer, and clientSecret for code flow. SAML requires idpEntityId, ssoURL, and x509Certificates. Catch and return 400 Bad Request with specific field validation errors.costlowin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[24] - deleteProviderConfig · delete-provider-config-not-founderrorWhenNo provider configuration exists for the given providerIdThrows
FirebaseAuthError with code 'auth/configuration-not-found'Required handlingTreat as idempotent in most cases — the config is already gone. If this is unexpected (e.g., double-delete race), log and handle gracefully. Do NOT surface this as an error to the end user in an admin UI — the outcome (config is gone) is the desired state.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[24] - getProviderConfig · get-provider-config-not-founderrorWhenNo provider configuration exists for the given providerIdThrows
FirebaseAuthError with code 'auth/configuration-not-found'Required handlingCatch and handle as 404. This is a normal condition when checking if a provider is configured. Do not assume provider exists — always catch this error in admin management workflows.costlowin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[24] - createTenant · create-tenant-invalid-tenant-iderrorWhentenantId in options is an empty string or invalid formatThrows
FirebaseAuthError with code 'auth/invalid-tenant-id'Required handlingValidate tenantId before calling createTenant. Tenant IDs must be non-empty strings. If using auto-generated IDs, omit the tenantId field and Firebase will generate one. Catch and return 400 Bad Request.costlowin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[22] - createTenant · create-tenant-missing-display-nameerrorWhendisplayName is required but missing from tenant optionsThrows
FirebaseAuthError with code 'auth/missing-display-name'Required handlingAlways include a displayName when creating tenants. The displayName is required by GCIP for tenant creation and is used in the Firebase Console and audit logs. Catch and return 400 with field validation details.costlowin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[23] - createTenant · create-tenant-quota-exceedederrorWhenProject has reached the maximum number of tenants for the GCIP planThrows
FirebaseAuthError with code 'auth/quota-exceeded'Required handlingCatch and surface as a billing/capacity limit. Contact Google Cloud support to increase tenant quota. Do not retry — the error is persistent until quota is increased or existing tenants are deleted. Alert operations team immediately.costhighin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[23] - updateTenant · update-tenant-not-founderrorWhenNo tenant exists for the provided tenantIdThrows
FirebaseAuthError with code 'auth/tenant-not-found'Required handlingCatch and handle as 404. Verify the tenantId is correct. This can occur if a tenant was deleted between reads. Do not retry — the tenant must be recreated if missing. Return 404 to calling service.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[22] - updateTenant · update-tenant-invalid-tenant-typeerrorWhenAttempting to change the tenant type (full_service vs lightweight) after creationThrows
FirebaseAuthError with code 'auth/invalid-tenant-type'Required handlingTenant type cannot be changed after creation. Remove the tenantType field from update requests if the type is already set. This is a permanent constraint — the only fix is to delete and recreate the tenant.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[23] - deleteTenant · delete-tenant-not-foundwarningWhenNo tenant exists for the provided tenantIdThrows
FirebaseAuthError with code 'auth/tenant-not-found'Required handlingTreat as idempotent — the tenant is already gone. In offboarding workflows, this is generally safe to ignore. Log the occurrence for audit trails (the tenant may have been deleted by a concurrent request or external process).costlowin prodimmediate exceptionusers seedegraded performancevisibilityvisibleSources[22] - getTenant · get-tenant-not-founderrorWhenNo tenant exists for the provided tenantIdThrows
FirebaseAuthError with code 'auth/tenant-not-found'Required handlingCatch and handle as 404. Always check tenant existence before performing tenant-scoped operations. If tenantId comes from user input or external systems, validate it with getTenant before calling authForTenant(). Return 404 to calling service.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[23] - setRules · set-rules-invalid-argumenterrorWhensource is null, undefined, empty string, or not a string/Buffer/objectThrows
FirebaseDatabaseError with code 'database/invalid-argument'Required handlingValidate rules source before calling setRules. The source must be a non-empty string (rules JSON), a Buffer containing rules, or a parsed object. Never pass null or empty string. This is a synchronous validation — no network call is made.costlowin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[25] - setRules · set-rules-permission-deniederrorWhenService account lacks firebaserules.rulesets.create IAM permission or Firebase Admin roleThrows
FirebaseDatabaseError with HTTP 403 / permission-deniedRequired handlingCatch and alert — this is a service account misconfiguration in the deployment environment. The service account requires the Firebase Admin SDK Service Agent role or firebaserules.rulesets.create permission. Do not retry. Alert the deployment pipeline — rules were NOT updated.costhighin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[25] - getDownloadURL · get-download-url-no-tokenerrorWhenFile exists in Cloud Storage but has no Firebase download token. Files uploaded directly via Google Cloud Storage APIs (not Firebase SDK) do not have download tokens by default.Throws
FirebaseError with code 'storage/no-download-token'Required handlingCatch and handle: create a download token by updating the file's metadata via the Firebase Console or by calling file.setMetadata() to add a firebaseStorageDownloadTokens metadata entry. Files uploaded via Firebase Client SDK automatically have tokens. Files uploaded via @google-cloud/storage SDK do NOT have tokens unless explicitly added. This is a common pitfall in hybrid upload architectures.costmediumin prodimmediate exceptionusers seelost datavisibilityvisibleSources[26] - getDownloadURL · get-download-url-file-not-founderrorWhenFile does not exist in the Cloud Storage bucketThrows
Error with HTTP 404 from Google Cloud Storage APIRequired handlingCatch HTTP 404 errors — this occurs when the file path is incorrect, the file was deleted, or the bucket name is wrong. Always verify file existence before generating download URLs in critical workflows. Return 404 to the calling client.costmediumin prodimmediate exceptionusers seelost datavisibilityvisibleSources[26] - executeGraphql · data-connect-invalid-argumenterrorWhenGraphQL query is empty, not a string, or options object is malformedThrows
FirebaseDataConnectError with code 'data-connect/invalid-argument'Required handlingCatch this error to surface developer mistakes during query construction. The most common cause is interpolating an undefined variable into the query template (producing an empty string) or passing a non-object as options. Log the query for debugging and return a 400-class error to upstream callers — do NOT retry.costmediumin prodimmediate exceptionusers seelost datavisibilityvisible - executeGraphql · data-connect-permission-deniederrorWhenService account lacks Data Connect access on the target service/connector, or the impersonated auth principal is denied by GraphQL auth directives.Throws
FirebaseDataConnectError with code 'data-connect/permission-denied' or 'data-connect/unauthenticated'Required handlingCatch and alert — this indicates either service-account IAM misconfiguration (Data Connect Editor / Admin role missing) or that the impersonated end-user lacks permission for the queried operation. Do NOT retry with the same credentials. For impersonation paths, propagate as 403 to the client.costhighin prodimmediate exceptionusers seeservice unavailablevisibilityvisible - executeGraphql · data-connect-network-errorerrorWhenNetwork request to the Data Connect REST endpoint failed (DNS failure, connection reset, gateway timeout, or 5xx response from Google Cloud).Throws
FirebaseDataConnectError with code 'data-connect/internal-error' or 'data-connect/unknown-error'Required handlingCatch and implement retry with exponential backoff for transient failures. Distinguish retriable (5xx, ECONNRESET) from non-retriable (4xx) errors by inspecting the wrapped error code. Surface persistent failures as 503 to the upstream caller so SLO alerts fire. Long-running migration scripts MUST checkpoint progress so a transient failure does not require a full restart.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[27] - executeGraphql · data-connect-query-errorerrorWhenServer rejected the GraphQL operation — typical causes are referenced table/column does not exist, type mismatch, or Postgres constraint violation (unique key, foreign key, not-null) on a mutation.Throws
FirebaseDataConnectError with code 'data-connect/query-error'Required handlingCatch and inspect the error message — the server returns the specific GraphQL error detail. Constraint violations are user-recoverable (e.g. surface 'email already exists' to the UI); schema mismatches indicate a developer bug and MUST be alerted. Do NOT retry — re-running the same query produces the same failure.costmediumin prodimmediate exceptionusers seelost datavisibilityvisible - verifyToken · phone-verify-token-invaliderrorWhenToken argument is not a string, is malformed (cannot be JWT-decoded), has the wrong issuer, wrong audience (Firebase project ID mismatch), missing/invalid signature, or no matching JWKS key id.Throws
FirebasePhoneNumberVerificationError with code 'phone-number-verification/invalid-token' or '/invalid-argument'Required handlingCatch and return 401 Unauthorized to the caller. Treat this as a hostile input — the most common production source is a forged or tampered token, NOT a legitimate user error. Log the verification failure for audit but do not echo the token contents to the client. DO NOT retry — a token that fails signature/issuer verification will never succeed.costhighin prodimmediate exceptionusers seelost datavisibilityvisible - verifyToken · phone-verify-token-expirederrorWhenPhone-verification JWT exp claim is in the pastThrows
FirebasePhoneNumberVerificationError with code 'phone-number-verification/expired-token'Required handlingCatch and return 401 Unauthorized. Distinguish expired tokens from invalid ones via error.code — expired tokens are a normal lifecycle event (the user's verification window closed) and the client should be instructed to restart the phone-verification flow, not retry the same token. DO NOT extend the trust window by ignoring the error.costhighin prodimmediate exceptionusers seelost datavisibilityvisibleSources[30] - verifyToken · phone-verify-project-or-network-errorerrorWhenApp was initialized without a project ID (no service-account credential and no GOOGLE_CLOUD_PROJECT env var), or the JWKS endpoint network fetch failed transiently.Throws
FirebasePhoneNumberVerificationError with code 'phone-number-verification/invalid-argument'Required handlingCatch and alert — for the project-id case this is a deployment-time misconfiguration that requires fixing the service-account credential or GOOGLE_CLOUD_PROJECT env var. For the JWKS network case, return 503 to the caller so SLO alerts fire and clients can retry. DO NOT silently fall back to trusting the unverified token.costhighin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[30] - TaskQueue.enqueue · task-queue-enqueue-already-existserrorWhenTaskOptions.id is set to an explicit value and a task with that ID already exists in the queue, or was deleted/executed within the last ~1 hour (deduplication window).Throws
FirebaseFunctionsError with code 'functions/task-already-exists'Required handlingCaller MUST either catch and treat this as idempotent success (task is already queued — no action needed), or use a different ID. Do NOT retry blindly — the same ID will fail again until the deduplication window expires. If at-least-once semantics are acceptable, catch and continue. If exactly-once is required, check error.code before deciding whether to surface the error upstream.costmediumin prodimmediate exceptionusers seelost transactionvisibilityvisible - TaskQueue.enqueue · task-queue-enqueue-permission-deniederrorWhenThe service account lacks the cloudtasks.tasks.create IAM permission, or the Cloud Tasks API is not enabled for the project.Throws
FirebaseFunctionsError with code 'functions/permission-denied'Required handlingThis is a deployment-time configuration error — fix the service account IAM binding before retrying. Grant roles/cloudtasks.enqueuer or a custom role with cloudtasks.tasks.create. Do NOT retry in code — the permission check is server-side and will fail repeatedly.costhighin prodimmediate exceptionusers seeservice unavailablevisibilityvisible - TaskQueue.enqueue · task-queue-enqueue-not-founderrorWhenThe Cloud Functions task-queue function referenced by functionName is not deployed or does not exist in the specified project/location.Throws
FirebaseFunctionsError with code 'functions/not-found'Required handlingVerify the function name is correct and deployed. In multi-environment setups, check that the function is deployed in the environment matching the Firebase app's project. Fail fast with an alert — tasks cannot be enqueued for a function that doesn't exist.costhighin prodimmediate exceptionusers seeservice unavailablevisibilityvisible - TaskQueue.delete · task-queue-delete-not-founderrorWhenThe task with the given ID does not exist in the queue — either it was already executed, already deleted, never enqueued, or the deduplication window has passed.Throws
FirebaseFunctionsError with code 'functions/not-found'Required handlingCaller SHOULD handle not-found as an idempotent no-op in most cancellation scenarios — the task may have already executed before the cancellation request arrived. If strict delivery-guarantees are required (task must not run), treat not-found as an error requiring investigation.costlowin prodimmediate exceptionusers seelost transactionvisibilityvisible - Channel.publish · eventarc-publish-invalid-argumenterrorWhenThe CloudEvent payload is missing required fields (id, source, type, specversion), contains an invalid field type, or the channel resource name is malformed.Throws
FirebaseEventarcError with code 'eventarc/invalid-argument'Required handlingValidate CloudEvent structure before publishing. Required fields: id (unique per event), source (URI), type (reverse-DNS string), specversion ('1.0'). A missing or malformed field throws immediately before the network call is made. Fix the event construction — retrying the same payload produces the same failure.costmediumin prodimmediate exceptionusers seelost transactionvisibilityvisible - Channel.publish · eventarc-publish-permission-deniederrorWhenThe publisher service account lacks eventarc.events.create permission on the Eventarc channel, or the Eventarc API is not enabled for the project.Throws
FirebaseEventarcError with code 'eventarc/unknown-error' (wraps 403 HTTP response)Required handlingGrant the service account roles/eventarc.eventPublisher or the specific eventarc.events.create permission. This is a deployment-time configuration error — retrying in code will not help. Alert on-call immediately as all event publications from this service are silently failing.costhighin prodimmediate exceptionusers seeservice unavailablevisibilityvisible - RemoteConfig.rollback · remote-config-rollback-version-not-founderrorWhenThe specified version number does not exist — it was never published, was deleted due to staleness (older than 90 days and no longer active), or exceeds the 300-version retention window.Throws
FirebaseRemoteConfigError with code 'remote-config/not-found'Required handlingCatch and alert. During an incident rollback, a not-found error means the target version is unavailable — fall back to the next-older known-good version. Use listVersions() to inspect the available version window before calling rollback(). Do NOT retry with the same version number.costhighin prodimmediate exceptionusers seeservice unavailablevisibilityvisible - RemoteConfig.rollback · remote-config-rollback-invalid-versionerrorWhenThe specified version number is invalid — it is greater than or equal to the current version, or is not a positive integer.Throws
FirebaseRemoteConfigError with code 'remote-config/failed-precondition' or 'remote-config/invalid-argument'Required handlingValidate that the target version number is less than the current template version (available from template.version.versionNumber after getTemplate()). Rollback to the same or newer version is logically invalid.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisible - RemoteConfig.getServerTemplate · remote-config-server-template-auth-errorerrorWhenThe service account lacks Firebase Remote Config Viewer or Admin permission, or the Remote Config REST API is not enabled for the project. Also fires if the credentials have expired (UNAUTHENTICATED).Throws
FirebaseRemoteConfigError with code 'remote-config/permission-denied' or 'remote-config/unauthenticated'Required handlingGrant roles/firebaseremoteconfig.viewer to the service account. If the credential has expired, re-initialize the Admin SDK. This error blocks all server-side personalization — surface as a startup error rather than letting it manifest as a runtime NullPointerException when using the template object.costhighin prodimmediate exceptionusers seedegraded performancevisibilityvisible - MachineLearning.createModel · ml-create-model-already-existserrorWhenA model with the same display name already exists in the project.Throws
FirebaseMachineLearningError with code 'machine-learning/already-exists'Required handlingCatch and either update the existing model via updateModel() or use a unique display name. In idempotent create-or-update flows, catch this error, retrieve the existing model, and call updateModel() with the new model file URI.costlowin prodimmediate exceptionusers seelost transactionvisibilityvisible - MachineLearning.createModel · ml-create-model-invalid-argumenterrorWhenThe model options are invalid — display name is empty, gcsTfliteUri is malformed, or the referenced GCS file is not a valid TFLite model.Throws
FirebaseMachineLearningError with code 'machine-learning/invalid-argument'Required handlingValidate model options before calling createModel(). Verify the GCS URI format (gs://bucket/path/to/model.tflite) and that the file exists and is a valid TFLite model. A malformed URI causes an immediate error before any upload attempt.costlowin prodimmediate exceptionusers seelost transactionvisibilityvisible - MachineLearning.publishModel · ml-publish-model-not-founderrorWhenThe model with the given modelId does not exist in the project — it was never created, or was deleted before publish was called.Throws
FirebaseMachineLearningError with code 'machine-learning/not-found'Required handlingCatch and fail the deployment pipeline with a clear error. In CI/CD model-deployment flows, treat this as a fatal error requiring manual intervention — a missing model cannot be auto-recovered by retrying.costmediumin prodimmediate exceptionusers seedegraded performancevisibilityvisible - MachineLearning.publishModel · ml-publish-model-failed-preconditionerrorWhenThe model is in a locked state due to a concurrent operation (e.g. the model file is still being processed or validated by Firebase ML).Throws
FirebaseMachineLearningError with code 'machine-learning/failed-precondition'Required handlingCatch and poll for the model to reach a non-locked state using getModel() before retrying publishModel(). Implement exponential backoff with a reasonable timeout (e.g. 60 seconds) — model processing is typically fast but can be slow for large models.costmediumin prodimmediate exceptionusers seedegraded performancevisibilityvisible - MachineLearning.deleteModel · ml-delete-model-not-founderrorWhenThe model with the given modelId does not exist — it was already deleted or the ID was never valid.Throws
FirebaseMachineLearningError with code 'machine-learning/not-found'Required handlingCaller SHOULD treat not-found as an idempotent success in cleanup workflows (the goal was to remove the model — it's already gone). If strict deletion confirmation is required, propagate the error as a deletion-failed alert.costlowin prodimmediate exceptionusers seelost transactionvisibilityvisible
Sources
Every postcondition cites at least one of these. Grouped by source type; numbered to match the footnotes above.
- [1]firebase.google.com/docs/auth/adminErrors
- [2]firebase.google.com/docs/auth/adminVerify Id Tokens
- [3]firebase.google.com/docs/reference/adminError Handling
- [4]firebase.google.com/docs/auth/adminManage Users
- [5]firebase.google.com/docs/auth/adminCustom Claims
- [6]cloud.google.com/firestore/docs/understand-error-codesUnderstand Error Codes
- [7]firebase.google.com/docs/firestore/query-dataGet Data
- [8]firebase.google.com/docs/firestore/best-practicesBest Practices
- [9]firebase.google.com/docs/firestore/manage-dataAdd Data
- [10]firebase.google.com/docs/cloud-messaging/error-codesError Codes
- [11]firebase.google.com/docs/cloud-messaging/send-messageSend Message
- [12]firebase.google.com/docs/cloud-messaging/send-messageSend Message
- [13]firebase.google.com/docs/database/adminStart
- [14]firebase.google.com/docs/database/adminSave Data
- [15]firebase.google.com/docs/auth/adminCreate Custom Tokens
- [16]firebase.google.com/docs/firestore/manage-dataTransactions
- [17]firebase.google.com/docs/cloud-messaging/manage-topicsManage Topics
- [19]firebase.google.com/docs/auth/adminManage Users
- [21]firebase.google.com/docs/remote-config/use-config-restUse Config Rest
- [29]firebase.google.com/docs/data-connect/error-codesError Codes
- [32]firebase.google.com/docs/functions/task-functionsTask Functions
- [37]cloudevents.io/blog/2021/04Introducing Cloudevents Sdk For Javascript
- [39]firebase.google.com/docs/eventarc/adminSend Events
- [40]firebase.google.com/docs/remote-config/automate-rcAutomate Rc
- [42]firebase.google.com/docs/remote-config/serverServer
- [43]firebase.google.com/docs/ml/manage-models-adminManage Models Admin
- [18]raw.githubusercontent.com/firebase/firebase-admin-node/masterfirebase/firebase-admin-node · auth-api-request.ts
- [20]raw.githubusercontent.com/firebase/firebase-admin-node/masterfirebase/firebase-admin-node · remote-config-api-client-internal.ts
- [22]github.com/firebase/firebase-admin-node/blobfirebase/firebase-admin-node · auth-api-request.ts
- [23]github.com/firebase/firebase-admin-node/blobfirebase/firebase-admin-node · error.ts
- [24]github.com/firebase/firebase-admin-node/blobfirebase/firebase-admin-node · base-auth.ts
- [25]github.com/firebase/firebase-admin-node/blobfirebase/firebase-admin-node · database.ts
- [26]github.com/firebase/firebase-admin-node/blobfirebase/firebase-admin-node · index.ts
- [27]github.com/firebase/firebase-admin-node/blobfirebase/firebase-admin-node · data-connect-api-client-internal.ts
- [28]github.com/firebase/firebase-admin-node/blobfirebase/firebase-admin-node · error.ts
- [30]github.com/firebase/firebase-admin-node/blobfirebase/firebase-admin-node · token-verifier.ts
- [31]github.com/firebase/firebase-admin-node/blobfirebase/firebase-admin-node · error.ts
- [33]github.com/firebase/firebase-admin-node/blobfirebase/firebase-admin-node · functions-api.ts
- [34]github.com/firebase/firebase-admin-node/blobfirebase/firebase-admin-node · error.ts
- [35]github.com/firebase/firebase-admin-node/blobfirebase/firebase-admin-node · eventarc.ts
- [36]github.com/firebase/firebase-admin-node/blobfirebase/firebase-admin-node · error.ts
- [38]github.com/firebase/firebase-admin-node/blobfirebase/firebase-admin-node · eventarc-client-internal.ts
- [41]github.com/firebase/firebase-admin-node/blobfirebase/firebase-admin-node · error.ts
- [44]github.com/firebase/firebase-admin-node/blobfirebase/firebase-admin-node · error.ts
Research notes
Curator notes from SOURCES.md captured when the profile was written so you can verify the reasoning, not just the rules.
Sources: firebase-admin
Contract Version: 1.0.0 Last Verified: 2026-02-25 Package Version: >=11.0.0 <14.0.0
Official Documentation
Error Handling
-
Admin SDK Error Handling https://firebase.google.com/docs/reference/admin/error-handling Describes two error categories: programming errors and API errors
-
Admin Authentication API Errors https://firebase.google.com/docs/auth/admin/errors Complete list of auth error codes and scenarios
-
FCM Error Codes https://firebase.google.com/docs/cloud-messaging/error-codes Firebase Cloud Messaging error codes and handling
-
Firestore Error Codes https://cloud.google.com/firestore/docs/understand-error-codes gRPC error codes used by Firestore (PERMISSION_DENIED, DEADLINE_EXCEEDED, etc.)
Service-Specific Documentation
-
Verify ID Tokens https://firebase.google.com/docs/auth/admin/verify-id-tokens Token verification patterns and error scenarios
-
Manage Users https://firebase.google.com/docs/auth/admin/manage-users User management operations: create, get, update, delete
-
Custom Claims https://firebase.google.com/docs/auth/admin/custom-claims Setting custom claims with size and key restrictions
-
Get Firestore Data https://firebase.google.com/docs/firestore/query-data/get-data Reading documents and checking existence
-
Add Firestore Data https://firebase.google.com/docs/firestore/manage-data/add-data Writing, updating, and deleting documents
-
Firestore Best Practices https://firebase.google.com/docs/firestore/best-practices Rate limiting, hot spots, quota management
-
Send FCM Messages https://firebase.google.com/docs/cloud-messaging/send-message Sending to devices, topics, and batches
-
Send to Topics https://firebase.google.com/docs/cloud-messaging/send-message#send-messages-to-topics Topic naming format and restrictions
-
Realtime Database Admin https://firebase.google.com/docs/database/admin/start Admin SDK setup and authentication
-
Save Realtime Database Data https://firebase.google.com/docs/database/admin/save-data Writing, updating, and deleting data
Security Vulnerabilities (CVEs)
CVE-2018-1000025 (PHP SDK Only)
Package: firebase-admin-php Affected Versions: 3.2.0 - 3.8.0 Fixed In: 3.8.1 Severity: HIGH Issue: Token signature verification bypass in IdTokenVerifier.php Impact: Allows forged JWTs with fake email addresses and user IDs Reference: https://www.cvedetails.com/cve/CVE-2018-1000025/ Relevance: Node.js SDK not affected, but highlights importance of proper token verification
CVE-2023-26115 (Node.js SDK)
Package: firebase-admin (via @google-cloud/firestore dependency) Affected Versions: firebase-admin@11.11.0 Fixed In: firebase-admin with @google-cloud/firestore@7.1.0 Severity: MEDIUM Issue: Dependency vulnerability in word-wrap package Reference: https://github.com/firebase/firebase-admin-node/discussions/2352 Reference: https://security.snyk.io/package/npm/firebase-admin Relevance: Indirect dependency issue, resolved by updating Firestore dependency
Other Vulnerabilities
- CVE-2023-36665: Critical vulnerability in protobufjs (CVSS 9.8) affecting firebase-admin@11.11.0
- CVE-2024-41818: High severity in fast-xml-parser (CVSS 7.5), fixed in 11.11.1
- Status: firebase-admin@13.6.0 (latest) is non-vulnerable
Community Resources
GitHub Issues & Discussions
-
FCM Error Handling Feature Request https://github.com/firebase/firebase-admin-node/issues/1192 Discussion about improved error handling for Cloud Messaging
-
FirebaseError Type Definition https://github.com/firebase/firebase-admin-node/issues/403 Issue about FirebaseError being interface vs class
-
Firestore Error Checking https://github.com/firebase/firebase-admin-node/issues/2257 Recommended way to check for Firestore errors
-
Error Handling Inconsistency (Python) https://github.com/firebase/firebase-admin-python/issues/347 Discussion about FirebaseError structure across SDKs
Code Examples
- Tabnine: firebase-admin.auth Examples https://www.tabnine.com/code/javascript/functions/firebase-admin/auth Real-world code examples of auth operations
Error Code Collections
- firebase-error-codes Repository https://github.com/maxzaleski/firebase-error-codes Community-maintained collection of Firebase error codes
NPM Package
- firebase-admin on NPM https://www.npmjs.com/package/firebase-admin Official package page with version history
Contract Design Rationale
Error Categories
Firebase Admin SDK explicitly divides errors into:
- Programming Errors - Bugs in code (null values, missing config, etc.)
- API Errors - Runtime issues (expired tokens, non-existent users, network failures)
Contract Focus: API errors only, as these require try-catch handling.
Error Structure
Every API error contains:
code(string) - Most reliable identifier (e.g., 'auth/invalid-uid', 'auth/user-not-found')message(string) - Human-readable description- Service-specific properties (e.g.,
error.codefor Firestore returns gRPC numeric codes)
Method Chain Pattern
Firebase Admin uses chained method calls:
// Authentication (2-level chains)
admin.auth().verifyIdToken(token)
admin.auth().createUser(properties)
// Firestore (3-4 level chains)
admin.firestore().collection('users').doc('id').get()
admin.firestore().collection('users').add(data)
// Messaging (2-level chains)
admin.messaging().send(message)
// Database (3-level chains)
admin.database().ref('path').once('value')
Analyzer Requirements:
- Support for 2-level property chains:
admin.auth().verifyIdToken() - Support for 3+ level chains:
admin.firestore().collection().doc().get() - Instance variable tracking:
const auth = admin.auth(); auth.verifyIdToken()
Function Coverage Priority
Top 10 Most Critical Functions:
verifyIdToken()- Token verification (security-critical)createUser()- User creation (duplicate email errors)getUser()- User lookup (not-found errors)get()(Firestore) - Document reads (permission denied, not found)add()(Firestore) - Document creates (quota exceeded)set()(Firestore) - Document writes (transaction contention)send()(Messaging) - Push notifications (invalid tokens)updateUser()- User updates (not-found, duplicate email)sendMulticast()- Batch messaging (partial failures)update()(Firestore) - Document updates (not found)
Severity Levels
All postconditions marked as ERROR severity because:
- Authentication errors can lead to security vulnerabilities
- Firestore errors can cause data loss or corruption
- Messaging errors result in failed notifications
- Database errors cause application failures
Testing Strategy
Fixtures Required:
- proper-error-handling.ts - Demonstrates correct try-catch with error.code checking
- missing-error-handling.ts - Shows missing error handling (should trigger violations)
- instance-usage.ts - Tests detection via instance variables
Expected Behavior:
- Analyzer should detect method calls across all 4 service areas
- Should support 2-4 level method chains
- Should track instance assignments (e.g.,
const auth = admin.auth())
Verification Notes
Error Code Format
- Authentication: String codes with 'auth/' prefix (e.g., 'auth/user-not-found')
- Firestore: gRPC numeric codes (e.g., 5 = NOT_FOUND, 7 = PERMISSION_DENIED)
- Messaging: String codes with 'messaging/' prefix
- Database: String codes (e.g., 'PERMISSION_DENIED')
Version Compatibility
Contract covers firebase-admin >=11.0.0 <14.0.0:
- v11.x: Stable API, active LTS
- v12.x: Current stable
- v13.x: Latest stable (as of 2026-02-25)
Major breaking changes between versions primarily affect initialization patterns, not error handling.
Future Enhancements
Additional Functions to Consider
listUsers()- Pagination errorsgeneratePasswordResetLink()- Email errors$transaction()(Firestore) - Transaction-specific errorssubscribeToTopic()(Messaging) - Subscription errors
Edge Cases to Add
- Token refresh patterns
- Batch operation partial failures
- Transaction retry strategies
- Rate limit header inspection
Changelog
1.0.0 (2026-02-25)
- Initial contract creation
- Covers 4 service areas: Auth, Firestore, Messaging, Database
- 25 functions with error handling requirements
- Based on firebase-admin v11-13 API