Natixar / natixar-frontend

The static front end of the Natixar SaaS platform
0 stars 5 forks source link

API Requests do not Check for Protocol Errors #78

Closed lepeuvedic-natixar closed 1 month ago

lepeuvedic-natixar commented 1 month ago

Problem

The functions passed as the transformResponse parameter to builder.query expect that the response will have a JSON body, but various network conditions can break this expectation.

Steps to Reproduce

  1. Enter wrong backend URLs in the environment (.env or environment variables) of the client, and it will receive 404 errors with HTML body.
  2. Authenticate and enter the Dashboard
  3. Press F12 and monitor the console: observe JSON parsing errors

Expected Behavior

Response processing shall only try to parse the body as JSON when the HTTP status code is 200 or 206 (OK or Partial Content). The commit 353d67516ca67b5cac19bcb65f2a165f03fa4187 corrects the problem for the /data/ranges (main) endpoint, but a verification and possible similar correction must be performed for all the other API calls (search createApi).

lepeuvedic-natixar commented 1 month ago

It's also possible to perturbate communications at the level of the proxy, but devs do not have access to this element of infrastructure. Note that the current status of all the components is available from the proxy status page.