Describe your environment
- Operating System version: macOS 10.15.7
- Firebase SDK version: 9.4.2
- Firebase Product: auth
- Node.js version: 14.16.0
- NPM version: 6.14.11
Describe the problem
Calling generatePasswordResetLink with a valid email that is "not registered" (or, in other words, is not tied to any user), results in auth/internal-error. We used to catch auth/user-not-found error code for cases where the email was not found, but it seems like the error code changed to EMAIL_NOT_FOUND. EMAIL_NOT_FOUND is not handled/mapped and therefore the response results in auth/internal-error. The error code is not present in the docs here, is it not handled on purpose then?
I would have thought an error code like this is something that could have its own error code and not default to auth/internal-error, hence this issue.
Or is to something to be reported on the official Firebase bug report site here? If so, then I am sorry for opening the issue here and I will report it on the Firebase website.
Relevant pieces of code I could (or could not) find:
- query for
EMAIL_NOT_FOUND response code: https://github.com/firebase/firebase-admin-node/search?q=EMAIL_NOT_FOUND
- default value if response code is not present:
|
const clientCodeKey = AUTH_SERVER_TO_CLIENT_CODE[serverErrorCode] || 'INTERNAL_ERROR'; |
- AuthClientErrorCode definition:
|
export class AuthClientErrorCode { |
- Auth server to client enum error codes:
|
const AUTH_SERVER_TO_CLIENT_CODE: ServerToClientCode = { |
I also went through the python sdk and it seems like EMAIL_NOT_FOUND is also not handled. Maybe it is on purpose then?
Steps to reproduce:
- Initialize firebase-admin app with a service account
- Call
generatePasswordResetLink with a valid email that is not tied to any user
- Catch error
Or curl command to REST API for quick testing:
curl 'https://identitytoolkit.googleapis.com/v1/accounts:sendOobCode?key=API_KEY' \
-H 'Content-Type: application/json' \
--data-binary '{"requestType":"PASSWORD_RESET","email":"[email protected]@example.com"}'
Error info:
{
code: 'auth/internal-error',
message: 'An internal error has occurred. Raw server response: "{"error":{"code":400,"message":"EMAIL_NOT_FOUND","errors":[{"message":"EMAIL_NOT_FOUND","domain":"global","reason":"invalid"}]}}"'
},
codePrefix: 'auth'
}
Relevant Code:
import * as admin from "firebase-admin";
admin.initializeApp({
credential: admin.credential.cert("GCP_SERVICE_ACCOUNT")
})
admin.auth().generatePasswordResetLink("[email protected]").catch(console.error).finally(process.exit);
Expected behaviour
EMAIL_NOT_FOUND is defined in AuthClientErrorCode and correctly mapped so that error.code does not return auth/internal-error but auth/email-not-found (or similar).
I will gladly provide more information if needed and if this is something that should be added, I think I would manage to make a PR for it. I have it mostly ready, but I am not sure if it is a desired behaviour to handle this error code, since it is not handled in the python sdk as well (from what I could gather).
Thank you!
Describe your environment
Describe the problem
Calling
generatePasswordResetLinkwith a valid email that is "not registered" (or, in other words, is not tied to any user), results inauth/internal-error. We used to catchauth/user-not-founderror code for cases where the email was not found, but it seems like the error code changed toEMAIL_NOT_FOUND.EMAIL_NOT_FOUNDis not handled/mapped and therefore the response results inauth/internal-error. The error code is not present in the docs here, is it not handled on purpose then?I would have thought an error code like this is something that could have its own error code and not default to
auth/internal-error, hence this issue.Or is to something to be reported on the official Firebase bug report site here? If so, then I am sorry for opening the issue here and I will report it on the Firebase website.
Relevant pieces of code I could (or could not) find:
EMAIL_NOT_FOUNDresponse code: https://github.com/firebase/firebase-admin-node/search?q=EMAIL_NOT_FOUNDfirebase-admin-node/src/utils/error.ts
Line 157 in 1862342
firebase-admin-node/src/utils/error.ts
Line 344 in 1862342
firebase-admin-node/src/utils/error.ts
Line 830 in 1862342
I also went through the python sdk and it seems like
EMAIL_NOT_FOUNDis also not handled. Maybe it is on purpose then?Steps to reproduce:
generatePasswordResetLinkwith a valid email that is not tied to any userOr curl command to REST API for quick testing:
Error info:
Relevant Code:
Expected behaviour
EMAIL_NOT_FOUNDis defined inAuthClientErrorCodeand correctly mapped so thaterror.codedoes not returnauth/internal-errorbutauth/email-not-found(or similar).I will gladly provide more information if needed and if this is something that should be added, I think I would manage to make a PR for it. I have it mostly ready, but I am not sure if it is a desired behaviour to handle this error code, since it is not handled in the python sdk as well (from what I could gather).
Thank you!