Skip to content

feat(Feature Versioning): add multi variate capabilities to the experimental update-flag endpoints#7955

Open
emyller wants to merge 14 commits into
mainfrom
feat/multivariate-update-flag-endpoints
Open

feat(Feature Versioning): add multi variate capabilities to the experimental update-flag endpoints#7955
emyller wants to merge 14 commits into
mainfrom
feat/multivariate-update-flag-endpoints

Conversation

@emyller

@emyller emyller commented Jul 6, 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 #7642

  • Refactors update-flag code for better typing and maintenance.
  • Introduces MV (multi variate) support for both experimental update-flags endpoints.
  • Behaviour is consistent to UX in the dashboard.
  • Makes a few properties optional, to allow for isolated changes to MVs — and other properties too, why not.

How did you test this code?

Unit tests.

How to review

4/5 raw effort.

3/5 if read commit-by-commit. Each is concern-isolated, and stack nicely.

@emyller emyller self-assigned this Jul 6, 2026
@vercel

vercel Bot commented Jul 6, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview, Comment Jul 10, 2026 6:56pm
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
flagsmith-frontend-preview Ignored Ignored Preview Jul 10, 2026 6:56pm
flagsmith-frontend-staging Ignored Ignored Preview Jul 10, 2026 6:56pm

Request Review

@coderabbitai

coderabbitai Bot commented Jul 6, 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: b3b64a6d-eef2-4b95-830f-32d696beeff2

📥 Commits

Reviewing files that changed from the base of the PR and between 42ea717 and 656a5ca.

📒 Files selected for processing (2)
  • api/features/models.py
  • docs/docs/integrating-with-flagsmith/flagsmith-api-overview/admin-api/updating-flags.md

📝 Walkthrough

Walkthrough

This pull request renames the update-flag endpoints, serializers, and services to Option A and Option B. It adds typed payload schemas and change-set dataclasses for feature values, multivariate options, and segment overrides. Versioning now uses shared helpers for feature-state and multivariate updates. Rollout code, routing, views, tests, OpenAPI schemas, and documentation are updated.

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


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 feature New feature or request and removed docs Documentation updates labels Jul 6, 2026
@emyller emyller force-pushed the feat/multivariate-update-flag-endpoints branch from 420e419 to d64e257 Compare July 7, 2026 01:00
@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 Jul 7, 2026
Comment thread api/tests/integration/conftest.py
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

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

passed  6 passed

Details

stats  6 tests across 4 suites
duration  40.7 seconds
commit  8c25092
info  🔄 Run: #18118 (attempt 1)

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

passed  3 passed

Details

stats  3 tests across 3 suites
duration  41.5 seconds
commit  8c25092
info  🔄 Run: #18118 (attempt 1)

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

passed  4 passed

Details

stats  4 tests across 3 suites
duration  38 seconds
commit  8c25092
info  🔄 Run: #18118 (attempt 1)

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

passed  7 passed

Details

stats  7 tests across 6 suites
duration  35 seconds
commit  8c25092
info  🔄 Run: #18118 (attempt 1)

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

passed  4 passed

Details

stats  4 tests across 3 suites
duration  42.8 seconds
commit  9d8dc5c
info  🔄 Run: #18142 (attempt 1)

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

passed  4 passed

Details

stats  4 tests across 3 suites
duration  45.4 seconds
commit  9d8dc5c
info  🔄 Run: #18142 (attempt 1)

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

passed  5 passed

Details

stats  5 tests across 4 suites
duration  34.1 seconds
commit  9d8dc5c
info  🔄 Run: #18142 (attempt 1)

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

passed  4 passed

Details

stats  4 tests across 2 suites
duration  11.7 seconds
commit  9d8dc5c
info  🔄 Run: #18142 (attempt 1)

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

passed  4 passed

Details

stats  4 tests across 3 suites
duration  34.3 seconds
commit  42ea717
info  🔄 Run: #18170 (attempt 1)

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

passed  4 passed

Details

stats  4 tests across 3 suites
duration  36.7 seconds
commit  42ea717
info  🔄 Run: #18170 (attempt 1)

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

passed  4 passed

Details

stats  4 tests across 3 suites
duration  37.7 seconds
commit  42ea717
info  🔄 Run: #18170 (attempt 1)

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

passed  1 passed

Details

stats  1 test across 1 suite
duration  53.9 seconds
commit  42ea717
info  🔄 Run: #18170 (attempt 1)

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

passed  5 passed

Details

stats  5 tests across 3 suites
duration  12.1 seconds
commit  656a5ca
info  🔄 Run: #18171 (attempt 1)

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

passed  2 passed

Details

stats  2 tests across 2 suites
duration  41 seconds
commit  656a5ca
info  🔄 Run: #18171 (attempt 1)

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

passed  6 passed

Details

stats  6 tests across 4 suites
duration  12.1 seconds
commit  656a5ca
info  🔄 Run: #18171 (attempt 1)

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

passed  1 passed

Details

stats  1 test across 1 suite
duration  59.5 seconds
commit  656a5ca
info  🔄 Run: #18171 (attempt 1)

@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Visual Regression

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 5

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
api/features/feature_states/serializers.py (1)

238-254: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

N+1 query in validate_segment_overrides.

One Segment.objects.filter(...).exists() query per segment override via validate_segment_id. Already flagged with a TODO — worth batching into a single filter(id__in=segment_ids, project_id=...).count() check once out of experimentation, as noted.

♻️ Possible batched check
-        for segment_id in segment_ids:
-            self.validate_segment_id(segment_id)
+        valid_count = Segment.objects.filter(
+            id__in=segment_ids, project_id=_environment(self.context).project_id
+        ).count()
+        if valid_count != len(segment_ids):
+            raise serializers.ValidationError(
+                "One or more segments not found in project"
+            )

Happy to open this as a follow-up if useful.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 39f7d2ea-874a-4876-9a95-d80d6825179b

📥 Commits

Reviewing files that changed from the base of the PR and between a7b0d21 and 8c25092.

📒 Files selected for processing (18)
  • api/api/urls/experiments.py
  • api/experimentation/services.py
  • api/features/feature_states/serializers.py
  • api/features/feature_states/types.py
  • api/features/feature_states/views.py
  • api/features/versioning/dataclasses.py
  • api/features/versioning/versioning_service.py
  • api/tests/integration/conftest.py
  • api/tests/integration/environments/identities/test_integration_identities.py
  • api/tests/integration/features/versioning/test_update_flag_endpoints.py
  • api/tests/integration/helpers.py
  • api/tests/unit/features/feature_states/test_serializers.py
  • api/tests/unit/features/feature_states/test_unit_feature_states_views.py
  • api/tests/unit/features/versioning/test_unit_versioning_versioning_service.py
  • docs/docs/deployment-self-hosting/observability/_events-catalogue.md
  • docs/docs/integrating-with-flagsmith/flagsmith-api-overview/admin-api/updating-flags.md
  • mcp/src/flagsmith_mcp/openapi.json
  • openapi.yaml

Comment thread api/features/feature_states/serializers.py
Comment thread api/features/versioning/versioning_service.py Outdated
Comment thread api/features/versioning/versioning_service.py Outdated
Comment thread api/tests/integration/features/versioning/test_update_flag_endpoints.py Outdated
return attrs


class UpdateFlagOptionASerializer(BaseFeatureUpdateSerializer[FeatureState]):

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.

Option A and Option B are becoming the new semantic for v1 and v2 ?

@emyller emyller Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

To the public, they already are. The refactor here happens for:

  1. Eliminate ambiguity, i.e. flag-update v1/v2 over feature versioning v1/v2.
  2. Make it consistent with user docs.
  3. Improve clarity of naming of the backend components.
👻Only certain spirits are expected to have different names depending on the realm they're in, but these are just code.

@Zaimwa9 Zaimwa9 Jul 10, 2026

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.

Ah ok, I didn't have context over the public documentation. Makes sense, thanks for the clarification. I thought on the opposite this changes were a specific case of renaming versioning v1 versus v2.

Just a NIT then if I may:
It looks like this example of the doc is missing the second request in Option A
image

If my understanding is correct, the override should be updated in a separate request. If my understanding is wrong please ignore 👍

Feel free to resolve this thread

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks. Option A here is indeed one request, but the docs make it confusing. I've improved things with 42ea717 — also getting rid of the "highest=1" slop.

Please note these are unrelated to the scope of the PR, though I think the improvement warrants piggybacking.

@emyller emyller marked this pull request as draft July 9, 2026 15:00
@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 Jul 10, 2026
@emyller emyller force-pushed the feat/multivariate-update-flag-endpoints branch from c4e9676 to 9d8dc5c Compare July 10, 2026 01:35
@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 Jul 10, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 7ed23c6d-926a-4bdb-9501-ab0991c865b6

📥 Commits

Reviewing files that changed from the base of the PR and between 8c25092 and 9d8dc5c.

📒 Files selected for processing (18)
  • api/api/urls/experiments.py
  • api/experimentation/services.py
  • api/features/feature_states/serializers.py
  • api/features/feature_states/types.py
  • api/features/feature_states/views.py
  • api/features/versioning/dataclasses.py
  • api/features/versioning/versioning_service.py
  • api/tests/integration/conftest.py
  • api/tests/integration/environments/identities/test_integration_identities.py
  • api/tests/integration/features/versioning/test_update_flag_endpoints.py
  • api/tests/integration/helpers.py
  • api/tests/unit/features/feature_states/test_serializers.py
  • api/tests/unit/features/feature_states/test_unit_feature_states_views.py
  • api/tests/unit/features/versioning/test_unit_versioning_versioning_service.py
  • docs/docs/deployment-self-hosting/observability/_events-catalogue.md
  • docs/docs/integrating-with-flagsmith/flagsmith-api-overview/admin-api/updating-flags.md
  • mcp/src/flagsmith_mcp/openapi.json
  • openapi.yaml

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
docs/docs/integrating-with-flagsmith/flagsmith-api-overview/admin-api/updating-flags.md (1)

235-238: 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

Clarify multivariate_options omission semantics.
State that omitting the field leaves existing options unchanged, while providing the array replaces the current set and deletes any omitted options.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: f88b0d43-16e9-4175-9878-67217361caf2

📥 Commits

Reviewing files that changed from the base of the PR and between 9d8dc5c and 42ea717.

📒 Files selected for processing (7)
  • api/features/feature_states/serializers.py
  • api/features/feature_states/types.py
  • api/features/models.py
  • api/features/versioning/dataclasses.py
  • api/features/versioning/versioning_service.py
  • api/tests/integration/features/versioning/test_update_flag_endpoints.py
  • docs/docs/integrating-with-flagsmith/flagsmith-api-overview/admin-api/updating-flags.md

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.

3 participants