Skip to content

Conversation

erka
Copy link
Contributor

@erka erka commented Oct 11, 2025

Add validation to segment deletion to prevent removing segments that are
referenced by flag rules or rollouts. This ensures data integrity by
checking all flags in the namespace before allowing segment deletion.

Closes #4183

Add validation to segment deletion to prevent removing segments that are
referenced by flag rules or rollouts. This ensures data integrity by
checking all flags in the namespace before allowing segment deletion.

Signed-off-by: Roman Dmytrenko <[email protected]>
@erka erka requested a review from a team as a code owner October 11, 2025 22:06
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Oct 11, 2025
@erka erka requested a review from Copilot October 11, 2025 22:07
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 adds validation to prevent deletion of segments that are currently referenced by flag rules or rollouts, ensuring data integrity by checking all flags in the namespace before allowing segment deletion.

  • Added validation logic to check for segment usage in flag rules and rollouts before deletion
  • Enhanced error messages to specify which flag and rule/rollout number is using the segment
  • Added comprehensive test coverage for various scenarios of segment usage

Reviewed Changes

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

File Description
internal/storage/environments/fs/flipt/segments.go Added validation logic to prevent deletion of segments referenced by flags
internal/storage/environments/fs/flipt/segments_test.go Added comprehensive test cases for segment deletion validation scenarios

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

Copy link

dosubot bot commented Oct 11, 2025

Related Documentation

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

How did I do? Any feedback?  Join Discord

@erka erka added the v2 Flipt v2 label Oct 11, 2025
Copy link

codecov bot commented Oct 11, 2025

Codecov Report

❌ Patch coverage is 84.61538% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 59.01%. Comparing base (4ab9d6b) to head (77d71a6).

Files with missing lines Patch % Lines
internal/storage/environments/fs/flipt/segments.go 84.61% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##               v2    #4879      +/-   ##
==========================================
+ Coverage   58.98%   59.01%   +0.03%     
==========================================
  Files         135      135              
  Lines       16861    16874      +13     
==========================================
+ Hits         9945     9959      +14     
+ Misses       6235     6234       -1     
  Partials      681      681              
Flag Coverage Δ
integrationtests 33.87% <0.00%> (-0.02%) ⬇️
unittests 49.76% <84.61%> (+0.04%) ⬆️

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.

@erka erka added automerge Used by Kodiak bot to automerge PRs bug labels Oct 12, 2025
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 bug size:L This PR changes 100-499 lines, ignoring generated files. v2 Flipt v2

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

V2: restricts deletion of segments that are currently in use

1 participant