Skip to content

fix(Segments): Improve and consolidate service for fetching overrides - #8548

Merged
emyller merged 2 commits into
mainfrom
fix/get-overrides-maybe-in-effect
Sep 18, 2026
Merged

emyller merged 2 commits into
mainfrom
fix/get-overrides-maybe-in-effect

Conversation

@emyller

@emyller emyller commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

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

  • 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

Contributes to #8412

The service get_overrides_in_effect was introduced as an indirect utility to gate a few use cases.

In each of these gates, all introduced in #8358, the service call is wrapped by an EXISTS clause, which hinders the problem this PR aims to solve. The motivation exists because get_overrides_in_effect becomes an entrypoint to fetch, well, overrides in effect — e.g. #8525. However, we need to fix:

  • Its name, because it "in effect" is not the intent of this service, and becomes misleading.
  • The unexpected duplication of FeatureSegment objects caused by the LEFT OUTER JOIN produced in the query (FVv1).

This refactor achieves the above, and also attemps to improve readability and simplify the code.

As an unexpected bonus, in every traced use case, querying is faster now in both FVv1 and FVv2. 🚀

How did you test this code?

Testing and local benchmarking.

@emyller emyller self-assigned this Sep 18, 2026
@emyller
emyller requested a review from a team as a code owner September 18, 2026 00:52
@emyller
emyller requested review from matthewelwell and removed request for a team September 18, 2026 00:52
@vercel

vercel Bot commented Sep 18, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated
docs Ready Ready Preview Sep 18, 2026 12:54am UTC
2 Skipped Deployments
Project Deployment Actions Updated
flagsmith-frontend-preview Ignored Ignored Preview Sep 18, 2026 12:54am UTC
flagsmith-frontend-staging Ignored Ignored Preview Sep 18, 2026 12:54am UTC

Request Review

@github-actions github-actions Bot added the api Issue related to the REST API label Sep 18, 2026
@coderabbitai

coderabbitai Bot commented Sep 18, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 33f30c22-ba44-4ed2-8389-9d2cfd3f3271

📥 Commits

Reviewing files that changed from the base of the PR and between 1fd274c and a5a15f4.

📒 Files selected for processing (6)
  • api/features/versioning/managers.py
  • api/segments/serializers.py
  • api/segments/services.py
  • api/segments/views.py
  • api/tests/unit/segments/test_unit_segments_services.py
  • docs/docs/deployment-self-hosting/observability/_events-catalogue.md

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The version manager now returns published feature versions that are live or scheduled, excluding superseded live versions. Segment services use this query for v2 environments and committed change-request states for v1 environments. Serialisation, segment listing, and deletion checks now include scheduled overrides. Unit tests cover v1 and v2 scenarios. Event catalogue references were updated.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to a5a15

Live and scheduled override handling remains gated to published versions, with no identified broken caller from the renamed query.


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 the fix label Sep 18, 2026
@github-actions

github-actions Bot commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Docker builds report

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

@emyller emyller changed the title fix(Segments): Improve robustness of override fetching entrypoint fix(Segments): Improve and consolidate service for fetching overrides Sep 18, 2026
@github-actions

github-actions Bot commented Sep 18, 2026

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

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

passed  2 passed

Details

stats  2 tests across 2 suites
duration  43.8 seconds
commit  443071c
info  🔄 Run: #20500 (attempt 1)

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

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

passed  3 passed

Details

stats  3 tests across 3 suites
duration  33.8 seconds
commit  443071c
info  🔄 Run: #20500 (attempt 1)

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

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

passed  1 passed

Details

stats  1 test across 1 suite
duration  46.5 seconds
commit  443071c
info  🔄 Run: #20500 (attempt 1)

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

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

passed  1 passed

Details

stats  1 test across 1 suite
duration  38.4 seconds
commit  a5a15f4
info  🔄 Run: #20501 (attempt 1)

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

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

passed  1 passed

Details

stats  1 test across 1 suite
duration  34.1 seconds
commit  443071c
info  🔄 Run: #20500 (attempt 1)

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

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

passed  1 passed

Details

stats  1 test across 1 suite
duration  33.4 seconds
commit  a5a15f4
info  🔄 Run: #20501 (attempt 1)

@github-actions

Copy link
Copy Markdown
Contributor

Visual Regression

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

@codecov

codecov Bot commented Sep 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.81%. Comparing base (095addd) to head (a5a15f4).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #8548   +/-   ##
=======================================
  Coverage   98.81%   98.81%           
=======================================
  Files        1620     1620           
  Lines       66186    66234   +48     
=======================================
+ Hits        65401    65449   +48     
  Misses        785      785           

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

@khvn26 khvn26 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This looks like a significant improvement to me, and the tests are excellent 👍

@emyller
emyller merged commit 49d957a into main Sep 18, 2026
34 checks passed
@emyller
emyller deleted the fix/get-overrides-maybe-in-effect branch September 18, 2026 11:26
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 docs Documentation updates fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants