Skip to content

Conversation

markphelps
Copy link
Collaborator

Summary

Fixes validation errors when using rollout value of 0 in variant flag distributions and percentage value of 0 in boolean flag threshold rollouts.

Problem

When updating a variant flag with a distribution rollout value of 0, the operation fails with a CUE validation error: incomplete value >=0 & <=100. This occurs because the omitempty tag on the Rollout field in Distribution and Percentage field in ThresholdRule causes zero values to be omitted during YAML serialization, leading to validation failure.

Changes

  • Modified internal/ext/common.go: Removed omitempty tags from:
    • Distribution.Rollout field
    • ThresholdRule.Percentage field
  • Added internal/ext/common_test.go: Comprehensive tests for YAML and JSON serialization with zero values
  • Added core/validation/testdata/valid_zero_values.yaml: Test data with rollout: 0 and percentage: 0
  • Modified core/validation/validate_test.go: Added test case for zero values validation

Testing

  • All existing tests pass
  • New tests verify zero values serialize correctly in both YAML and JSON
  • CUE validation now passes for rollout: 0 and percentage: 0
  • Linting and formatting checks pass

Backward Compatibility

This change is backward compatible since:

  • Existing YAML files with rollout/percentage values continue to work
  • The only change is that zero values are now explicitly serialized instead of omitted
  • CUE validation is more consistent

Fixes #4677

Remove omitempty tag from Distribution.Rollout and ThresholdRule.Percentage
fields to fix CUE validation errors when these fields have zero values.

- Fixed Distribution.Rollout field to always serialize, even when 0
- Fixed ThresholdRule.Percentage field to always serialize, even when 0
- Added comprehensive tests for YAML and JSON serialization with zero values
- Added CUE validation test case with zero values

Fixes #4677

Signed-off-by: Claude <[email protected]>
@markphelps markphelps requested a review from a team as a code owner September 3, 2025 14:10
@markphelps markphelps added the v2 Flipt v2 label Sep 3, 2025
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Sep 3, 2025
Copy link

dosubot bot commented Sep 3, 2025

Related Documentation

Checked 2 published document(s). No updates required.

How did I do? Any feedback?  Join Discord

Copy link

codecov bot commented Sep 3, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 62.52%. Comparing base (1841e10) to head (27788c7).
⚠️ Report is 1 commits behind head on v2.

Additional details and impacted files
@@           Coverage Diff           @@
##               v2    #4678   +/-   ##
=======================================
  Coverage   62.52%   62.52%           
=======================================
  Files         131      131           
  Lines       15510    15510           
=======================================
  Hits         9698     9698           
  Misses       5139     5139           
  Partials      673      673           
Flag Coverage Δ
integrationtests 36.91% <ø> (ø)
unittests 52.63% <ø> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@markphelps markphelps added the automerge Used by Kodiak bot to automerge PRs label Sep 3, 2025
@markphelps markphelps requested review from erka and Copilot September 3, 2025 14:25
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes validation errors when using zero values (0 or 0.0) for rollout percentages in variant flag distributions and threshold rollouts in boolean flags by removing the omitempty YAML/JSON tags that were causing these fields to be omitted during serialization.

  • Removes omitempty tags from Distribution.Rollout and ThresholdRule.Percentage fields in struct definitions
  • Adds comprehensive test coverage for YAML and JSON serialization with zero values
  • Adds validation test data and test case to ensure CUE validation works with zero values

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
internal/ext/common.go Removes omitempty tags from Rollout and Percentage fields to ensure zero values are serialized
internal/ext/common_test.go Adds comprehensive tests for YAML and JSON serialization with zero rollout and percentage values
core/validation/validate_test.go Adds test case to verify validation passes with zero values
core/validation/testdata/valid_zero_values.yaml Test data containing rollout: 0 and percentage: 0 configurations

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@kodiakhq kodiakhq bot merged commit 0336881 into v2 Sep 3, 2025
44 of 45 checks passed
@kodiakhq kodiakhq bot deleted the fix/issue-4677-rollout-zero-validation branch September 3, 2025 14:36
@github-project-automation github-project-automation bot moved this to Done in Flipt V2 Sep 3, 2025
Copy link

dosubot bot commented Sep 3, 2025

Documentation updates

Checked 2 published document(s). No updates required.

How did I do? Any feedback?  Join Discord

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Used by Kodiak bot to automerge PRs size:L This PR changes 100-499 lines, ignoring generated files. v2 Flipt v2
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Variant rule's rollout value of 0 causes validation error
2 participants