Skip to content

feat(__future__): Delete a flag's segment override - #8307

Merged
khvn26 merged 5 commits into
mainfrom
feat/update-flag-delete
Aug 16, 2026
Merged

feat(__future__): Delete a flag's segment override#8307
khvn26 merged 5 commits into
mainfrom
feat/update-flag-delete

Conversation

@khvn26

@khvn26 khvn26 commented Aug 15, 2026

Copy link
Copy Markdown
Member
  • I have read the Contributing Guide.
  • I have added information to docs/ if required so people know about the feature.
  • I have filled in the "Changes" section below.
  • I have filled in the "How did you test this code" section below.

Changes

Closes #8300

Adds DELETE /api/__future__/environments/{environment_key}/features/{feature_id}/segment-overrides/{segment_id}/, so a caller can remove one segment override without sending the whole list back through PUT.

Behaviour follows the sibling verbs:

  • MANAGE_SEGMENT_OVERRIDES gates it. A caller with no permission on the environment gets 404; one holding only UPDATE_FEATURE_STATE gets 403.
  • 409 where change requests are enabled, logging features.flag.update_rejected.
  • 404 for non-existing segment overrides.
  • Versioning-agnostic.
  • Remaining overrides keep their priorities.

Updated documentation: https://docs-git-feat-update-flag-delete-flagsmith.vercel.app/managing-flags/updating-flags

How did you test this code?

Added integration tests.

@khvn26
khvn26 requested review from a team as code owners August 15, 2026 13:36
@khvn26
khvn26 requested review from bakirFS and emyller and removed request for a team August 15, 2026 13:36
@vercel

vercel Bot commented Aug 15, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

3 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs Ignored Ignored Preview Aug 16, 2026 2:37pm
flagsmith-frontend-preview Ignored Ignored Preview Aug 16, 2026 2:37pm
flagsmith-frontend-staging Ignored Ignored Preview Aug 16, 2026 2:37pm

Request Review

@coderabbitai

coderabbitai Bot commented Aug 15, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: dd036277-80a6-4162-b6f0-9bd3c684c04c

📥 Commits

Reviewing files that changed from the base of the PR and between 2ed87a3 and 3219551.

📒 Files selected for processing (2)
  • api/tests/unit/features/future/__init__.py
  • api/tests/unit/features/future/test_unit_future_services.py

Included review availability: Your plan includes up to 8 reviews per rolling hour; 6 remain after this review.


📝 Walkthrough

Walkthrough

The change adds an experimental DELETE endpoint for one segment override. The endpoint authenticates requests, checks permissions, validates workflow restrictions, and deletes the override transactionally. Enabled environments publish a new version. The response contains the updated flag state. Integration and query-count tests cover deletion, errors, permissions, workflows, versions, logs, and state preservation. OpenAPI, user documentation, and event catalogue references are updated.

Estimated code review effort: 4 (Complex) | ~45 minutes

Merge Risk: ⚪ Minimal · up to 32195

This PR adds a localized endpoint for deleting a single segment override, with documented permission and error behavior; no actionable merge-blocking risk remains beyond normal checks and review.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added api Issue related to the REST API docs Documentation updates labels Aug 15, 2026
@github-actions github-actions Bot removed the docs Documentation updates label Aug 15, 2026
@github-actions

github-actions Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Docker builds report

Image Build Status Security report
ghcr.io/flagsmith/flagsmith-e2e:pr-8307 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-api-test:pr-8307 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-frontend:pr-8307 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-api:pr-8307 Finished ✅ Results
ghcr.io/flagsmith/flagsmith:pr-8307 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-private-cloud:pr-8307 Finished ✅ Results

@github-actions github-actions Bot added the feature New feature or request label Aug 15, 2026
@codecov

codecov Bot commented Aug 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.78%. Comparing base (a013d7b) to head (6bb85dc).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #8307   +/-   ##
=======================================
  Coverage   98.78%   98.78%           
=======================================
  Files        1604     1604           
  Lines       64335    64426   +91     
=======================================
+ Hits        63551    63642   +91     
  Misses        784      784           

☔ View full report in Codecov by Harness.
📢 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.

@github-actions

github-actions Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor
✅ private-cloud · depot-ubuntu-latest-arm-16 — run #19445 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)

passed  3 passed

Details

stats  3 tests across 3 suites
duration  39.5 seconds
commit  6bb85dc
info  🔄 Run: #19445 (attempt 1)

🗂️ Previous results
✅ private-cloud · depot-ubuntu-latest-16 — run #19445 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-16)

passed  2 passed

Details

stats  2 tests across 2 suites
duration  32.9 seconds
commit  6bb85dc
info  🔄 Run: #19445 (attempt 1)

✅ oss · depot-ubuntu-latest-arm-16 — run #19445 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-arm-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  45.6 seconds
commit  6bb85dc
info  🔄 Run: #19445 (attempt 1)

✅ oss · depot-ubuntu-latest-16 — run #19445 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  34.5 seconds
commit  6bb85dc
info  🔄 Run: #19445 (attempt 1)

✅ private-cloud · depot-ubuntu-latest-arm-16 — run #19442 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)

passed  3 passed

Details

stats  3 tests across 3 suites
duration  37.5 seconds
commit  3219551
info  🔄 Run: #19442 (attempt 1)

✅ private-cloud · depot-ubuntu-latest-16 — run #19442 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-16)

passed  2 passed

Details

stats  2 tests across 2 suites
duration  47.6 seconds
commit  3219551
info  🔄 Run: #19442 (attempt 1)

✅ oss · depot-ubuntu-latest-arm-16 — run #19442 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-arm-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  45.4 seconds
commit  3219551
info  🔄 Run: #19442 (attempt 1)

✅ oss · depot-ubuntu-latest-16 — run #19442 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  34.6 seconds
commit  3219551
info  🔄 Run: #19442 (attempt 1)

✅ private-cloud · depot-ubuntu-latest-arm-16 — run #19434 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  37.6 seconds
commit  2ed87a3
info  🔄 Run: #19434 (attempt 1)

✅ private-cloud · depot-ubuntu-latest-16 — run #19434 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-16)

passed  3 passed

Details

stats  3 tests across 3 suites
duration  32.6 seconds
commit  2ed87a3
info  🔄 Run: #19434 (attempt 1)

✅ oss · depot-ubuntu-latest-arm-16 — run #19434 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-arm-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  46.8 seconds
commit  2ed87a3
info  🔄 Run: #19434 (attempt 1)

✅ oss · depot-ubuntu-latest-16 — run #19434 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  41.3 seconds
commit  2ed87a3
info  🔄 Run: #19434 (attempt 1)

@github-actions

github-actions Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Visual Regression

19 screenshots compared. See report for details.
View full report

khvn26 added a commit to Flagsmith/flagsmith-cli that referenced this pull request Aug 15, 2026
Flagsmith/flagsmith#8307 adds
`DELETE …/features/{id}/segment-overrides/{segment_id}/`, so removing one
override no longer means replacing the whole set.

That takes the read-modify-write out of `flag delete --segment`: the
surviving overrides are neither read nor restated, so a concurrent change
to one can't be lost, and the endpoint's answer is the whole flag, as it
is for the writes. `echoOverrides` and `echoVariants` go with it —
restating an override's weights only mattered because a replacing write
inherits the environment default's when `variants` is omitted.

The override rows are still read, for two reasons a 404 doesn't cover:
the prompt names the segment, and a segment with no override should be
caught before asking rather than after.
Comment thread api/tests/integration/features/future/test_flag_endpoint.py Outdated
@github-actions github-actions Bot added docs Documentation updates feature New feature or request and removed feature New feature or request docs Documentation updates labels Aug 16, 2026
emyller
emyller previously approved these changes Aug 16, 2026
Comment thread api/features/future/services.py
Comment thread api/tests/integration/features/future/test_flag_endpoint.py Outdated
@emyller

emyller commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Left a couple non-blocking comments.

@github-actions github-actions Bot added docs Documentation updates feature New feature or request and removed feature New feature or request docs Documentation updates labels Aug 16, 2026
@github-actions github-actions Bot added docs Documentation updates feature New feature or request and removed feature New feature or request docs Documentation updates labels Aug 16, 2026
@github-actions github-actions Bot added docs Documentation updates feature New feature or request and removed feature New feature or request docs Documentation updates labels Aug 16, 2026

@emyller emyller 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.

LGTM

@khvn26
khvn26 merged commit b3b2b31 into main Aug 16, 2026
35 checks passed
@khvn26
khvn26 deleted the feat/update-flag-delete branch August 16, 2026 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api Issue related to the REST API feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DELETE update-flag endpoint for individual overrides

2 participants