-
Notifications
You must be signed in to change notification settings - Fork 19
[FSSDK-11552] Add holdout support and refactor decision logic #422
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
base: master
Are you sure you want to change the base?
Conversation
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.
Prisma Cloud has found errors in this PR ⬇️
…ecision-logic-fssdk11552
- Changed loop from 'for _, holdout := range holdouts' to 'for i := range holdouts' - Created proper pointer 'holdout := &holdouts[i]' to avoid address-of-iteration-variable issue - This fixes the security warning where all iterations would point to the same memory location - All tests passing Resolves Prisma Cloud security scan: Incorrect access of indexable resource
- Implemented holdout parsing from datafile with global/specific/exclusion logic - Added MapHoldouts() to process holdout relationships with feature flags - Implemented GetHoldoutsForFlag() to retrieve applicable holdouts per flag - Fixed bucketer initialization to use pointer (interface value) - Created comprehensive unit tests for HoldoutService (11 test cases) - Added integration test with real bucketer and evaluator - Added GetHoldoutsForFlag() mock method to helpers_test.go All tests passing (decision and config packages) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
- Added 3 unit tests for GetHoldoutsForFlag() in config_test.go - Created holdout_test.go with 7 comprehensive mapper tests: - Empty holdouts - Global holdouts with exclusions - Specific holdouts with inclusions - Non-running holdouts filtering - Mixed global and specific holdouts - Audience conditions mapping - Variations and traffic allocation mapping - Fixed govet shadow linting error in holdout_service.go line 105 All tests passing. Improves code coverage for new holdout functionality. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
| // Add specifically included holdouts | ||
| if included, exists := includedHoldouts[flagID]; exists { | ||
| applicableHoldouts = append(applicableHoldouts, included...) | ||
| } | ||
|
|
||
| // Add global holdouts (if not excluded) | ||
| isExcluded := false | ||
| if _, exists := excludedHoldouts[flagID]; exists { | ||
| isExcluded = true | ||
| } | ||
|
|
||
| if !isExcluded { | ||
| applicableHoldouts = append(applicableHoldouts, globalHoldouts...) | ||
| } |
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.
Global holdouts will take precedence over local holdouts. This seems opposite of that. Also can we add one test case that covers the precedence scenario ?
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.
We can add two more tests here
- Global vs local holdout priority test
- Excluded flag should not appear in
flagHoldoutsMap
Per jira ticket:
Changes:
Jira ticket:
https://optimizely-ext.atlassian.net/browse/FSSDK-11552