Skip to content

feat: add delete-segment-override experimental endpoint#6383

Merged
gagantrivedi merged 2 commits intomainfrom
feat/delete-segment-override-endpoint
Dec 10, 2025
Merged

feat: add delete-segment-override experimental endpoint#6383
gagantrivedi merged 2 commits intomainfrom
feat/delete-segment-override-endpoint

Conversation

@gagantrivedi
Copy link
Member

@gagantrivedi gagantrivedi commented Dec 8, 2025

Thanks for submitting a PR! Please check the boxes below:

  • 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?
  • I have used a Conventional Commit title for this Pull Request

Changes

Implements issue #6234 - adds endpoint to delete segment overrides for a feature in a given environment.

Endpoint: POST /api/experiments/environments/{environment_key}/delete-segment-override/

Request body:

  • feature: {name: "x"} OR {id: 123}
  • segment: {id: 456}

Response: 204 No Content

Features:

  • Works with both V1 and V2 feature versioning
  • V1: Direct deletion of FeatureSegment
  • V2: Creates new version, removes segment override, publishes
  • Reuses UPDATE_FEATURE_STATE permission
  • Blocked when workflow/change requests are enabled
  • Returns 400 if segment override doesn't exist

How did you test this code?

Adds unit tests

@gagantrivedi gagantrivedi requested a review from a team as a code owner December 8, 2025 06:57
@gagantrivedi gagantrivedi requested review from Zaimwa9 and removed request for a team December 8, 2025 06:57
@vercel
Copy link

vercel bot commented Dec 8, 2025

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

3 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
docs Ignored Ignored Preview Dec 10, 2025 4:09am
flagsmith-frontend-preview Ignored Ignored Preview Dec 10, 2025 4:09am
flagsmith-frontend-staging Ignored Ignored Preview Dec 10, 2025 4:09am

@github-actions github-actions bot added the api Issue related to the REST API label Dec 8, 2025
@gagantrivedi gagantrivedi force-pushed the feat/delete-segment-override-endpoint branch from e00b4f7 to f2337bc Compare December 8, 2025 07:08
@github-actions github-actions bot added the feature New feature or request label Dec 8, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Dec 8, 2025

Docker builds report

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

@codecov
Copy link

codecov bot commented Dec 8, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.06%. Comparing base (32e9bc5) to head (3ed8373).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff            @@
##             main    #6383    +/-   ##
========================================
  Coverage   98.05%   98.06%            
========================================
  Files        1289     1289            
  Lines       46162    46293   +131     
========================================
+ Hits        45264    45395   +131     
  Misses        898      898            

☔ 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.

@khvn26 khvn26 self-requested a review December 8, 2025 11:33
@khvn26 khvn26 self-assigned this Dec 8, 2025
Copy link
Member

@khvn26 khvn26 left a comment

Choose a reason for hiding this comment

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

Just a handful of comments; otherwise, looks good.

Base automatically changed from feat/experimental-flag-update-endpoints to main December 10, 2025 02:39
Implements issue #6234 - adds endpoint to delete segment overrides
for a feature in a given environment.

Endpoint: POST /api/experiments/environments/{environment_key}/delete-segment-override/

Request body:
- feature: {name: "x"} OR {id: 123}
- segment: {id: 456}

Response: 204 No Content

Features:
- Works with both V1 and V2 feature versioning
- V1: Direct deletion of FeatureSegment
- V2: Creates new version, removes segment override, publishes
- Reuses UPDATE_FEATURE_STATE permission
- Blocked when workflow/change requests are enabled
- Returns 400 if segment override doesn't exist

Files changed:
- versioning_service.py: Add delete_segment_override() with V1/V2 dispatch
- serializers.py: Add DeleteSegmentOverrideSerializer
- views.py: Add delete_segment_override view
- experiments.py: Add URL route
- tests: Add 9 test cases covering all scenarios

🤖 Generated with [Claude Code](https://claude.com/claude-code)
@gagantrivedi gagantrivedi force-pushed the feat/delete-segment-override-endpoint branch from f2337bc to 6dde16c Compare December 10, 2025 03:55
@github-actions github-actions bot added feature New feature or request and removed feature New feature or request labels Dec 10, 2025
- Update swagger tag from "Experimental - Feature States" to "experimental"
  to match other experimental endpoints
- Refactor delete_segment_override to use AuthorData dataclass instead of
  separate user/api_key parameters for consistency with other functions
@github-actions github-actions bot added feature New feature or request and removed feature New feature or request labels Dec 10, 2025
@gagantrivedi gagantrivedi requested a review from khvn26 December 10, 2025 04:10
Copy link
Member

@khvn26 khvn26 left a comment

Choose a reason for hiding this comment

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

LGTM now 👍

@gagantrivedi gagantrivedi merged commit 9e584f1 into main Dec 10, 2025
29 checks passed
@gagantrivedi gagantrivedi deleted the feat/delete-segment-override-endpoint branch December 10, 2025 11:01
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.

2 participants