Closed SilentM0ng00se closed 1 year ago
Hey @SilentM0ng00se,
Thank you for the report.
The contextTargets are intentional, but there is some backward compatibility logic that is missing.
For example:
it('customer test case', async () => {
const userUuid = '1234';
const userContextObject = {
kind: 'bob',
key: userUuid,
};
await td.update(
td
.flag('my-feature-flag-1')
.variationForContext('bob', userUuid, false)
.fallthroughVariation(false),
);
const valueA = await client.variation('my-feature-flag-1', userContextObject, 'default');
expect(valueA).toEqual(false);
await td.update(
td
.flag('my-feature-flag-1')
.variationForContext('bob', userUuid, true)
.fallthroughVariation(false),
);
const valueB = await client.variation('my-feature-flag-1', userContextObject, 'default');
expect(valueB).toEqual(true);
});
This test would pass when using a non-user context type. This was written against v8 of the SDK, but likely the same bug affects both.
When the context is a user there is some special logic that needs applied that is currently missing in test data.
Do you need this resolved in specifically v7, or would v8 be fine?
FYI development of this project has moved: https://github.com/launchdarkly/js-core/tree/main/packages/sdk
Additionally it is now published to a new package: @launchdarkly/node-server-sdk
Thank you, Ryan
Filed internally as 211542
@kinyoklion Ah, thats good to know. Thanks for the quick response. I have been using the work around mentioned in my post above so v8 would be fine :)
@SilentM0ng00se
This has been released in 8.1.1
There is a test included for specifically this case as well: https://github.com/launchdarkly/js-core/blob/9d60361a2dbd10670496a6b5bc723f07a86e82cd/packages/shared/sdk-server/__tests__/LDClient.evaluation.test.ts#L141
Thank you, Ryan
This issue is marked as stale because it has been open for 30 days without activity. Remove the stale label or comment, or this will be closed in 7 days.
Describe the bug When using TestData as the
updateProcessor
, setting the variation for the user and checking the value always returns the fallback value.To reproduce
Note: Just executing steps 1, 4 and 5 are enough to reproduce the issue.
TestData
as theupdateProcessor
Create a variation for the user with flag variation as
false
andfallbackVariation
asfalse
Use the client to check the value. (it returns false)
Update the variation for the user with flag variation as
true
fallbackVariation asfalse
Use the client to check the value. (it returns false)
Expected behavior In step 5 above, It should return
true
Logs N/A
SDK version
7.0.1
Language version, developer tools Node version
v18.13.0
OS/platform macOS - Ventura
Additional context I believe this is stemming from the missing
targets
object in the output ofTestDataFlagBuilder.build
. The object instead is namedcontextTargets
. Not sure if this is intentionalBelow is the code snpppet from the
test_data.js
file line # 259259 > baseFlagObject.contextTargets = contextTargets;
If i change this tobaseFlagObject.targets = contextTargets;
, it worksWorkaround
Use
ifMatch
andthenReturn
when setting flags