fix(bug): rescue BaseService::ThrottlingError when calculating Custom… #3653
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
::Invoices::CustomerUsageService
can raiseBaseService::ThrottlingError
whenapply_taxes
istrue
andcustomer_provider_taxation?
istrue
.If the controller does not handle this, the user will receive a 500 error.
This PR does not fix the throttling error because its out of our control, but inform the user to try again later in a nicer way than a error 500.
Sentry error
https://lago.sentry.io/issues/6336411980/?project=6370067
Steps to reproduce
Have an organization with Anrok provider configured
Have a invoice for an Anrok customer
call api GET
customers/<customer_external_id>/current_usage
.Apply taxes is
true
by default.The ThrottlingError may be raised and return a 500 error.
Result
With the rescue in place, the user would get a response like this when ThrottlingError happens