Skip to content
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

Merged
merged 2 commits into from
Oct 24, 2024
Merged

feat: Detect undefined variations #2563

merged 2 commits into from
Oct 24, 2024

Conversation

thomaspoignant
Copy link
Owner

@thomaspoignant thomaspoignant commented Oct 23, 2024

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

  • I have tested this code
  • I have added unit test to cover this code
  • I have followed the contributing guide

Copy link

netlify bot commented Oct 23, 2024

Deploy Preview for go-feature-flag-doc-preview canceled.

Name Link
🔨 Latest commit ba8abd6
🔍 Latest deploy log https://app.netlify.com/sites/go-feature-flag-doc-preview/deploys/671a3c08ea9070000851e150

Copy link

codecov bot commented Oct 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.39%. Comparing base (ad84c27) to head (ba8abd6).
Report is 2 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

count += p
if _, ok := variations[k]; !ok {
return fmt.Errorf("invalid percentage: variation %s does not exists", k)
Copy link

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?

Suggested change
return fmt.Errorf("invalid percentage: variation %s does not exists", k)
return fmt.Errorf("invalid percentage: variation %s does not exist", k)

Copy link

sonarcloud bot commented Oct 24, 2024

@thomaspoignant thomaspoignant merged commit a1955f0 into main Oct 24, 2024
22 checks passed
@thomaspoignant thomaspoignant deleted the feat-2562 branch October 24, 2024 12:29
@kna
Copy link

kna commented Oct 25, 2024

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(feature) Detect undefined variations with the linter
2 participants