Skip to content

feat(experimentation): expose experiment rollout in API responses#7858

Draft
gagantrivedi wants to merge 2 commits into
feat/experiment-rolloutfrom
feat/experiment-rollout-read
Draft

feat(experimentation): expose experiment rollout in API responses#7858
gagantrivedi wants to merge 2 commits into
feat/experiment-rolloutfrom
feat/experiment-rollout-read

Conversation

@gagantrivedi

Copy link
Copy Markdown
Member

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.

Note

Stacked on #7851 (base branch feat/experiment-rollout). Review/merge that first; this PR's diff is just the read-representation on top. I'll retarget to main once #7851 merges.

Changes

Contributes to

Follow-up to #7851, which left experiment_rollout write-only. This exposes it on read so the UI can display the configured rollout.

The rollout isn't stored as a single field — on read it's reassembled from its two sources of truth:

  • rollout_percentage ← the rollout segment's PERCENTAGE_SPLIT condition value
  • enabled / feature_state_value / multivariate_feature_state_values ← the live segment-override feature state (resolved the same v1/v2-aware way as ExperimentFeatureSerializer does for env-level allocations)

A get_experiment_rollout(experiment) service returns this shape (mirroring the write input), and ExperimentListSerializer exposes it via a read-only experiment_rollout field — so it appears on list, retrieve, and the rollout action responses. The write-only input field stays on the base serializer (mirrors the metrics pattern); returns null when no rollout is configured.

How did you test this code?

Unit tests (all green locally) + mypy, ruff, the test linter, and docgen:

  • Service: get_experiment_rollout reassembles the representation for v1 and v2 environments, and returns None when no rollout exists.
  • API: GET experiment detail returns the populated experiment_rollout, and null when absent.
  • Full experimentation suite (228 tests) passes — no regression from adding the field to the read representation.

Add a read representation of the experiment rollout, reassembled from the
rollout segment's percentage-split condition and the live segment-override
feature state (v1 and v2), exposed on the experiment list/detail/rollout
responses via ExperimentListSerializer. The write-only input field is kept
on the base serializer.
@vercel

vercel Bot commented Jun 24, 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 24, 2026 8:29am
flagsmith-frontend-preview Ignored Ignored Preview Jun 24, 2026 8:29am
flagsmith-frontend-staging Ignored Ignored Preview Jun 24, 2026 8:29am

Request Review

@github-actions github-actions Bot added api Issue related to the REST API docs Documentation updates feature New feature or request and removed docs Documentation updates labels Jun 24, 2026
@codecov

codecov Bot commented Jun 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 98.59%. Comparing base (7c3d4fa) to head (a6d03fb).

Files with missing lines Patch % Lines
api/experimentation/services.py 91.66% 1 Missing ⚠️
Additional details and impacted files
@@                     Coverage Diff                     @@
##           feat/experiment-rollout    #7858      +/-   ##
===========================================================
- Coverage                    98.60%   98.59%   -0.01%     
===========================================================
  Files                         1473     1468       -5     
  Lines                        57669    57687      +18     
===========================================================
+ Hits                         56863    56879      +16     
- Misses                         806      808       +2     

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

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.

1 participant