-
Notifications
You must be signed in to change notification settings - Fork 1
fix: non-bandit flags return string assignment #238
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
3881f2d
to
fe23022
Compare
e3c041a
to
43078e9
Compare
43078e9
to
264202c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving as-is although it would be nice to have a couple more test cases:
- bandit happy path
- non-bandit variation in flag with a bandit variation/allocation
expect(precomputedConfiguration).toEqual({ action: null, variation: 'nike' }); | ||
}); | ||
|
||
it('should return the assigned variation if a flag is not a bandit', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙌
|
||
it('should return the assigned variation if a flag is not a bandit', () => { | ||
const precomputedConfiguration = client.getBanditAction('not-a-bandit-flag', 'default'); | ||
expect(precomputedConfiguration).toEqual({ action: null, variation: 'control' }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also consider a situation where a flag IS a bandit flag, but they got assigned a non-bandit variation.
Also we should be using mocks to make sure the proper event loggers are called or not
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also consider a situation where a flag IS a bandit flag, but they got assigned a non-bandit variation.
For the precomputed response, wouldn't that be the same situation? The flag would be in flags
but not in bandits
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also we should be using mocks to make sure the proper event loggers are called or not
Updated! And I also added the happy path case of a bandit flag with a bandit variation
const precomputedFlag = this.getPrecomputedFlag(flagKey); | ||
if (!precomputedFlag) { | ||
logger.warn(`${loggerPrefix} No assigned variation. Flag not found: ${flagKey}`); | ||
return { variation: defaultValue, action: null }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Returning this if the precomputed flag is not found, otherwise returning the precomputed flag assignment if the bandit could not be evaluated. Makes sense
a83d1e1
to
7dbd361
Compare
} catch (error) { | ||
logger.error(`${loggerPrefix} Error logging bandit action: ${error}`); | ||
} | ||
return { variation: assignedVariation, action: banditEvent.action }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Returning the banditEvent.action
is interesting here. Are you counting on it being undefined | null
? If so please return that directly - or is it preforming randomization in this case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we ax this line all together, just keeping that final return with optional chaining and null coalesce:
return { variation: assignedVariation, action: banditEvent?.action ?? null }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry banditEvaluation.action
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All good I misread it ✅
Tests will pass after Eppo-exp/sdk-test-data#123 is merged
Fixes scenario where a bandit flag is assigned to a non-bandit variation. Instead of returning the programmatic default, we want to return the assigned variation when
getBanditAction
is called.See also: Eppo-exp/sdk-test-data#123