@JasonMortonNZ opened this Issue on May 18th 2022 Contributor

At present if a 429 response is returned from an API request the UI would show a generic error message. We would like to provide a more specific custom error message for this response code, indicating the user has sent too many requests in a given amount of time.

This is required to complete the rate limiting feature (dev-2437) on cloud and will improve uptime, cloud performance and customer experience.

@justinvelluppillai commented on June 8th 2022 Contributor

I will add this to the current milestone as it is a dependency for improving rate limiting on Cloud

@peterhashair commented on June 21st 2022 Contributor

I am not too sure if I am on the right track here. I think to prepend this before the line. Would that works?

   // load rate limit page if status code 429
        if (http_response_code() === 429) {
            $view = new view('<a class='mention' href='https://github.com/API'>@API</a>/rateLimit');
            return $view->render();
        }

https://github.com/matomo-org/matomo/blob/3f9a00f1447450b5fa3fb18170ed5943b5c83f50/plugins/API/Controller.php#L56

@justinvelluppillai commented on June 21st 2022 Contributor

I was expecting more likely something in AjaxHelper.ts where it currently handles all errors with 'Something went wrong' (except 504 gets a different message). Maybe worth running this by @bx80 to devise a plan here

@peterhashair commented on June 23rd 2022 Contributor

@JasonMortonNZ just a question on the UI changes, currently the UI shows this error message for the API endpoints
image

  • I could update this message to mention rate-limiting as a possible cause. This will be a simple change.
  • I could detect 429 as a response code and show different messages.

I suggest using option 2. I can use this text there.

image

@sgiehl commented on June 24th 2022 Member

I would suggest to maybe not directly implement any screen or custom message in Matomo itself, as it's quite cloud related only.
It might make more sense to trigger a javascript event whenever a request fails with an unexpected response code.
That way the cloud plugin could hook into that event and display a custom message.
This would later also allow to handle any other response code, we might need to introduce on cloud

@tsteur commented on June 25th 2022 Member

I could detect 429 as a response code and show different messages.

This would be ideal @peterhashair . We would want to handle the 429 error directly in core and then show a message. However, the message will need to be different so it works for regular On-Premise users too. The Cloud team will then maybe want to overwrite the message/translation.

I would suggest to maybe not directly implement any screen or custom message in Matomo itself, as it's quite cloud related only.

The idea was to have this in core so that other On-Premise users can benefit from this as well as some would already have some rate limiting configured and as always we would then ideally also document this behaviour in an FAQ so making it more clear when others set it up in the future.

Powered by GitHub Issue Mirror