Flagsmith client does not behave correctly in MultiProvider setup
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
- Configure
WebMultiProvideras follows:const multiProvider = new WebMultiProvider( [ { provider: new FlagsmithClientProvider(), }, { provider: new ProviderB(), } ], new FirstMatchStrategy() ); - Ensure that:
- Feature flag
"xxx"is not defined inFlagsmithClientProvider. - Feature flag
"xxx"is defined astrueinProviderB.
- Feature flag
- Request the flag
"xxx"usingmultiProvider.
Expected Behavior
- The flag
"xxx"should resolve totrue, as it is defined inProviderB.
Actual Behavior
- The resolved value is always
false, even thoughProviderBhas"xxx"set totrue.
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.
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?
cc @tiagoapolo here! Also @kyle-ssg !
@beeme1mr Would you please assign this issue and https://github.com/open-feature/js-sdk-contrib/issues/1232 to me? Thanks!