Skip to content

fix(experiments): resolve environment-level variant allocations#7805

Merged
Zaimwa9 merged 5 commits into
mainfrom
fix/experiment-env-allocations
Jun 19, 2026
Merged

fix(experiments): resolve environment-level variant allocations#7805
Zaimwa9 merged 5 commits into
mainfrom
fix/experiment-env-allocations

Conversation

@Zaimwa9

@Zaimwa9 Zaimwa9 commented Jun 17, 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

Fix experiment list serialiser to return environment-level variant allocations instead of feature-level defaults. Order experiments by newest first.

  • ExperimentFeatureSerializer.get_multivariate_options looks up the environment's feature state and overlays the actual percentage_allocation per multivariate option
  • order_by("-created_at") on the experiments queryset

How did you test this code?

Manually — created an experiment whose environment-level allocation differs from the feature default and confirmed the serialiser returns the correct percentages. Verified the list endpoint returns newest experiments first.

…rder by newest

ExperimentFeatureSerializer now looks up the environment's feature state
to return the actual percentage allocations instead of the feature-level
defaults. Prefetch the related state values to avoid N+1 queries.
Order experiments list by newest first.
@Zaimwa9 Zaimwa9 requested a review from a team as a code owner June 17, 2026 15:36
@Zaimwa9 Zaimwa9 requested review from khvn26 and removed request for a team June 17, 2026 15:36
@vercel

vercel Bot commented Jun 17, 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 Jun 19, 2026 7:48am
flagsmith-frontend-preview Ignored Ignored Preview Jun 19, 2026 7:48am
flagsmith-frontend-staging Ignored Ignored Preview Jun 19, 2026 7:48am

Request Review

@github-actions github-actions Bot added api Issue related to the REST API fix labels Jun 17, 2026
@github-actions

github-actions Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Docker builds report

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

@Zaimwa9 Zaimwa9 requested review from gagantrivedi and removed request for khvn26 June 17, 2026 15:37
@github-actions

github-actions Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

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

passed  1 passed

Details

stats  1 test across 1 suite
duration  41.7 seconds
commit  a56947b
info  🔄 Run: #17590 (attempt 1)

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

passed  1 passed

Details

stats  1 test across 1 suite
duration  38 seconds
commit  a56947b
info  🔄 Run: #17590 (attempt 1)

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

failed  1 failed

Details

stats  1 test across 1 suite
duration  51.5 seconds
commit  a56947b
info  📦 Artifacts: View test results and HTML report
🔄 Run: #17590 (attempt 1)

Failed tests

firefox › tests/project-permission-test.pw.ts › Project Permission Tests › Project-level permissions control access to features, environments, audit logs, and segments @enterprise

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

passed  1 passed

Details

stats  1 test across 1 suite
duration  44.4 seconds
commit  d5c1e2f
info  🔄 Run: #17591 (attempt 1)

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

passed  1 passed

Details

stats  1 test across 1 suite
duration  36.9 seconds
commit  d5c1e2f
info  🔄 Run: #17591 (attempt 1)

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

failed  1 failed

Details

stats  1 test across 1 suite
duration  49.2 seconds
commit  d5c1e2f
info  📦 Artifacts: View test results and HTML report
🔄 Run: #17591 (attempt 1)

Failed tests

firefox › tests/project-permission-test.pw.ts › Project Permission Tests › Project-level permissions control access to features, environments, audit logs, and segments @enterprise

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

passed  1 passed

Details

stats  1 test across 1 suite
duration  32 seconds
commit  758b907
info  🔄 Run: #17609 (attempt 1)

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

passed  1 passed

Details

stats  1 test across 1 suite
duration  44.6 seconds
commit  758b907
info  🔄 Run: #17609 (attempt 1)

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

failed  1 failed

Details

stats  1 test across 1 suite
duration  44.9 seconds
commit  758b907
info  📦 Artifacts: View test results and HTML report
🔄 Run: #17609 (attempt 1)

Failed tests

firefox › tests/project-permission-test.pw.ts › Project Permission Tests › Project-level permissions control access to features, environments, audit logs, and segments @enterprise

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

passed  1 passed

Details

stats  1 test across 1 suite
duration  41.6 seconds
commit  9c8b3f1
info  🔄 Run: #17658 (attempt 1)

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

passed  1 passed

Details

stats  1 test across 1 suite
duration  37.4 seconds
commit  9c8b3f1
info  🔄 Run: #17658 (attempt 1)

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

passed  2 passed

Details

stats  2 tests across 2 suites
duration  9.6 seconds
commit  9c8b3f1
info  🔄 Run: #17658 (attempt 1)

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

passed  2 passed

Details

stats  2 tests across 2 suites
duration  55.9 seconds
commit  9c8b3f1
info  🔄 Run: #17658 (attempt 1)

@github-actions github-actions Bot added fix and removed fix labels Jun 17, 2026
@github-actions

github-actions Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Visual Regression

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

@codecov

codecov Bot commented Jun 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.58%. Comparing base (8977abe) to head (9c8b3f1).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7805   +/-   ##
=======================================
  Coverage   98.58%   98.58%           
=======================================
  Files        1465     1465           
  Lines       56889    56925   +36     
=======================================
+ Hits        56082    56118   +36     
  Misses        807      807           

☔ 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 added fix and removed fix labels Jun 18, 2026
Comment thread api/tests/unit/experimentation/test_experiment_views.py Outdated
Comment thread api/experimentation/serializers.py Outdated
Comment thread api/experimentation/serializers.py
Comment thread api/experimentation/serializers.py
@github-actions github-actions Bot added fix and removed fix labels Jun 19, 2026
@Zaimwa9 Zaimwa9 merged commit 72a7df9 into main Jun 19, 2026
32 checks passed
@Zaimwa9 Zaimwa9 deleted the fix/experiment-env-allocations branch June 19, 2026 07:58
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 fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants