flagsmith-js-client icon indicating copy to clipboard operation
flagsmith-js-client copied to clipboard

Add error condition for missing environmentID and api fields

Open tiagoapolo opened this issue 8 months ago • 2 comments

In order to validate if FLAGSMITH ON FLAGSMITH failed we need to add a validation for both environmentID and api fields and throw an error in case they're not set

tiagoapolo avatar Jun 19 '25 21:06 tiagoapolo

Issues we need to solve:

Flagsmith frontend

  1. On SDK initialization error, the fallback screen is Maintenance Mode, no matter the error:
  • We should give access to the dashboard with default flags (similar to flags not created in the FoF instance)
  • We show a warning that the SDK has not been properly initialized
  • Be more specific on the SDK Error

Steps to reproduce:

  • Empty FoF (environmentID is empty and api is empty)
  1. Infinite loading: If environmentID and FoF are provided but wrong, the SDK doesn't raise an error and onChange is never triggered. Which should cascade to store.loaded and give access to the app.
  • In the frontend, we should add a fallback path (in case of FoF) to consider that initialization failed
  • Would give access to the dashboard with default flags and warning

Steps to reproduce:

  • Provide FoF URL and corrupt the environmentID key

SDK We don't raise errors on invalid credentials when initializing the SDK for exemple. So the SDK is initialized and the following calls throw errors on specific methods that are not handled. We need to better handle the following errors:

  • 404 => Wrong FoF URL (potential permanent issue, misconfiguration or server temporary down)
  • 403 => Correct URL but wrong Key (configuration issue)

Potential solution could be that for FoF, the SDK pings the server with the credentials to validate them

@tiagoapolo @kyle-ssg

Zaimwa9 avatar Jun 24 '25 08:06 Zaimwa9

To be replaced with #324

Zaimwa9 avatar Jul 17 '25 07:07 Zaimwa9