js-sdk-contrib icon indicating copy to clipboard operation
js-sdk-contrib copied to clipboard

Flagsmith client does not behave correctly in MultiProvider setup

Open belaczek opened this issue 9 months ago • 3 comments

Bug Report: MultiProvider Does Not Fallback to Secondary Provider while using FlagsmithClientProvider

Description

When using WebMultiProvider with FirstMatchStrategy, the expected behavior is that if a flag is not defined in the primary provider (FlagsmithClientProvider), the system should fallback to the next provider (ProviderB). However, this does not happen as expected.

Reproduction Steps

  1. Configure WebMultiProvider as follows:
    const multiProvider = new WebMultiProvider(
      [
        {
          provider: new FlagsmithClientProvider(),
        },
        {
          provider: new ProviderB(),
        }
      ],
      new FirstMatchStrategy()
    );
    
  2. Ensure that:
    • Feature flag "xxx" is not defined in FlagsmithClientProvider.
    • Feature flag "xxx" is defined as true in ProviderB.
  3. Request the flag "xxx" using multiProvider.

Expected Behavior

  • The flag "xxx" should resolve to true, as it is defined in ProviderB.

Actual Behavior

  • The resolved value is always false, even though ProviderB has "xxx" set to true.

Possible Cause

It seems that FirstMatchStrategy only fallback to the second provider when the first one evaluates to ErrorCode.FLAG_NOT_FOUND. However, when FlagsmithClientProvider does not find a flag, it throws TypeMismatchError.

belaczek avatar Mar 14 '25 15:03 belaczek

Hey @belaczek, thanks for letting us know. I'll circle in the Flagsmith team to see if they can look into it. It does appear that the provider doesn't set the reason as FLAG_NOT_FOUND. @dabeeeenster is this information available in the the Flagsmith SDK? If so, could the provider be updated to return the expected reason?

beeme1mr avatar Mar 14 '25 16:03 beeme1mr

cc @tiagoapolo here! Also @kyle-ssg !

dabeeeenster avatar Mar 14 '25 16:03 dabeeeenster

@beeme1mr Would you please assign this issue and https://github.com/open-feature/js-sdk-contrib/issues/1232 to me? Thanks!

rolodato avatar Mar 17 '25 15:03 rolodato