-
-
Notifications
You must be signed in to change notification settings - Fork 158
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
feat: Detect undefined variations #2563
Conversation
✅ Deploy Preview for go-feature-flag-doc-preview canceled.
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2563 +/- ##
==========================================
+ Coverage 84.81% 85.39% +0.57%
==========================================
Files 100 100
Lines 4346 4436 +90
==========================================
+ Hits 3686 3788 +102
+ Misses 535 518 -17
- Partials 125 130 +5 ☔ View full report in Codecov by Sentry. |
internal/flag/rule.go
Outdated
count += p | ||
if _, ok := variations[k]; !ok { | ||
return fmt.Errorf("invalid percentage: variation %s does not exists", k) |
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 might be better to change like this?
return fmt.Errorf("invalid percentage: variation %s does not exists", k) | |
return fmt.Errorf("invalid percentage: variation %s does not exist", k) |
|
Thanks! |
Description
In this PR we had a new check when validating a feature flag to check if we reference an undefined variation in one of the rule configuration.
The effect of this PR is double, it will allow the linter to detect those issues and it will discard this flag (and log an error) for misconfigured flags.
Closes issue(s)
Resolve #2562
Checklist