firebase-admin
semver
>=11.0.0 <15.0.0postconditions97functions44last verified2026-06-11coverage score100%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]
Sources
Every postcondition cites at least one of these. Numbered to match the footnotes above.
- [1]firebase.google.com/docs/authhttps://firebase.google.com/docs/auth/admin/errors
- [2]firebase.google.com/docs/authhttps://firebase.google.com/docs/auth/admin/verify-id-tokens
- [3]firebase.google.com/docs/referencehttps://firebase.google.com/docs/reference/admin/error-handling
- [4]firebase.google.com/docs/authhttps://firebase.google.com/docs/auth/admin/manage-users
- [5]firebase.google.com/docs/authhttps://firebase.google.com/docs/auth/admin/custom-claims
- [6]cloud.google.com/firestore/docshttps://cloud.google.com/firestore/docs/understand-error-codes
- [7]firebase.google.com/docs/firestorehttps://firebase.google.com/docs/firestore/query-data/get-data
- [8]firebase.google.com/docs/firestorehttps://firebase.google.com/docs/firestore/best-practices
- [9]firebase.google.com/docs/firestorehttps://firebase.google.com/docs/firestore/manage-data/add-data
- [10]firebase.google.com/docs/cloud-messaginghttps://firebase.google.com/docs/cloud-messaging/error-codes
- [11]firebase.google.com/docs/cloud-messaginghttps://firebase.google.com/docs/cloud-messaging/send-message
- [12]firebase.google.com/docs/cloud-messaginghttps://firebase.google.com/docs/cloud-messaging/send-message#send-messages-to-topics
- [13]firebase.google.com/docs/databasehttps://firebase.google.com/docs/database/admin/start
- [14]firebase.google.com/docs/databasehttps://firebase.google.com/docs/database/admin/save-data
- [15]firebase.google.com/docs/authhttps://firebase.google.com/docs/auth/admin/create-custom-tokens
- [16]firebase.google.com/docs/firestorehttps://firebase.google.com/docs/firestore/manage-data/transactions
- [17]firebase.google.com/docs/cloud-messaginghttps://firebase.google.com/docs/cloud-messaging/manage-topics
- [18]raw.githubusercontent.com/firebase/firebase-admin-nodehttps://raw.githubusercontent.com/firebase/firebase-admin-node/master/src/auth/auth-api-request.ts
- [19]firebase.google.com/docs/authhttps://firebase.google.com/docs/auth/admin/manage-users#import_users
- [20]raw.githubusercontent.com/firebase/firebase-admin-nodehttps://raw.githubusercontent.com/firebase/firebase-admin-node/master/src/remote-config/remote-config-api-client-internal.ts
- [21]firebase.google.com/docs/remote-confighttps://firebase.google.com/docs/remote-config/use-config-rest#quotas
- [22]github.com/firebase/firebase-admin-nodehttps://github.com/firebase/firebase-admin-node/blob/master/src/auth/auth-api-request.ts
- [23]github.com/firebase/firebase-admin-nodehttps://github.com/firebase/firebase-admin-node/blob/master/src/utils/error.ts
- [24]github.com/firebase/firebase-admin-nodehttps://github.com/firebase/firebase-admin-node/blob/master/src/auth/base-auth.ts
- [25]github.com/firebase/firebase-admin-nodehttps://github.com/firebase/firebase-admin-node/blob/master/src/database/database.ts
- [26]github.com/firebase/firebase-admin-nodehttps://github.com/firebase/firebase-admin-node/blob/master/src/storage/index.ts
Need a different package?
Request a profile