Affected: All SDKs
Symptoms
The following error can occur after starting an experiment:
Sample mismatch ratio detected
These results are not valid.
Cause
There are many ways an SRM can occur, but the most common is that the randomization method is incorrect.
Solution
Check against the list to see if any of the following issues apply:
- If using a JavaScript-based SDK, read Understanding sample ratios to ensure your SDK version will not run into the issues described.
- Make sure to evaluate the experiment flag as close as possible to when the end user encounters the experiment in your application. In most SDKs, this is accomplished by using the SDK's
variation
call. For more information, read Evaluating flags. - If using the Subscribing to flag changes feature, be aware that the change listener will only fire a feature event if a change in the flag's value is detected. This means that if a context's flag value doesn't change from when the SDK is initialized to when the context is identified, no feature event will be sent to LaunchDarkly, and the context will not be entered into the experiment. The solution for this is to use the
variation
method instead as described earlier. - When calling
identify
, make sure theidentify
call has completed before performing any flag evaluations. For more information, read Identifying and changing contexts. - Add a
flush
call after evaluating the experiment flag to ensure the feature event is sent to LaunchDarkly and not lost. This is particularly necessary if there's a page redirect that happens when the variation and or track event is invoked. For more information, read Flushing events.
If the above checklist does not resolve your issue, submit a support ticket and provide the following information to help expedite the troubleshooting process:
- SDK and version
- Code snippets of the following (if applicable):
- SDK configuration and initialization
- How the application evaluates the experiment flag and the surrounding conditions upon which the evaluation is done
-
identify
call
- Enable Enhanced Support