Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FR] Improve exception handling for rate limiting #666

Closed
skion opened this issue Jan 4, 2023 · 3 comments · Fixed by #695
Closed

[FR] Improve exception handling for rate limiting #666

skion opened this issue Jan 4, 2023 · 3 comments · Fixed by #695

Comments

@skion
Copy link
Contributor

skion commented Jan 4, 2023

Is your feature request related to a problem? Please describe.

When using the SDK to create email action links, such as for password reset or email verifications, Firebase is strongly rate limiting for good reason. However, it is currently impossible to (programmatically) detect whether the reason for failure was indeed rate limiting, or something else, since in both cases a generic InvalidArgumentError exception is raised.

Describe the solution you'd like

A way to distinguish rate limiting from other client or server side errors, so that my API is able to return 429 or 503 responses with a Retry-After header instead of a generic 500 response in those cases.

Describe alternatives you've considered

In order to prevent my API from returning generic 500 I'm considering to implement my own rate limiting in front now. However, that is less elegant since I would need to heuristically match Firebase's rate limiting algorithm in order to prevent emitting 500's anyway.

Additional context

Currently the RESET_PASSWORD_EXCEED_LIMIT error code from Firebase is swallowed and converted into a INVALID_ARGUMENT code, because this type of exception is not special-cased:

InvalidArgumentError('Error while calling Auth service (RESET_PASSWORD_EXCEED_LIMIT).')

Note that the same holds for building email verification links:

InvalidArgumentError('Error while calling Auth service (TOO_MANY_ATTEMPTS_TRY_LATER).')

In both cases the original code is not introspectable in the exception, except by parsing the error string.

@google-oss-bot
Copy link

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

@mohitCodepy
Copy link

@lahirumaramba , Is anyone actively working on this issue ? If not then please assign me, thanks

@skion
Copy link
Contributor Author

skion commented Jun 1, 2023

@lahirumaramba @pragatimodi FWIW I linked a PR a while ago that I believe solves this problem. Can someone have a look at it?

@lahirumaramba lahirumaramba linked a pull request Mar 5, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants