Skip to content

fix(storage): prevent deletion of segments in use by flags#4879

Merged
kodiakhq[bot] merged 1 commit into
v2from
rd/v2/delete-segment
Oct 14, 2025
Merged

fix(storage): prevent deletion of segments in use by flags#4879
kodiakhq[bot] merged 1 commit into
v2from
rd/v2/delete-segment

Conversation

@erka

@erka erka commented Oct 11, 2025

Copy link
Copy Markdown
Contributor

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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.

@dosubot

dosubot Bot commented Oct 11, 2025

Copy link
Copy Markdown

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
@codecov

codecov Bot commented Oct 11, 2025

Copy link
Copy Markdown

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).
⚠️ Report is 5 commits behind head on v2.

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

@markphelps markphelps left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

looks great!

@kodiakhq
kodiakhq Bot merged commit 1150cec into v2 Oct 14, 2025
58 of 60 checks passed
@kodiakhq
kodiakhq Bot deleted the rd/v2/delete-segment branch October 14, 2025 23:00
@github-project-automation github-project-automation Bot moved this to Done in Flipt V2 Oct 14, 2025
@dosubot

dosubot Bot commented Oct 14, 2025

Copy link
Copy Markdown

Documentation Updates

Checked 4 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 bug 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.

V2: restricts deletion of segments that are currently in use

3 participants