Skip to content

feat(__future__): Identify MV options by key in experimental update-flags endpoint#8000

Open
emyller wants to merge 3 commits into
feat/multivariate-update-flag-endpointsfrom
feat/update-flags-identify-mvs-by-key
Open

feat(__future__): Identify MV options by key in experimental update-flags endpoint#8000
emyller wants to merge 3 commits into
feat/multivariate-update-flag-endpointsfrom
feat/update-flags-identify-mvs-by-key

Conversation

@emyller

@emyller emyller commented Jul 13, 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

Timeline for context

  1. New — and experimental — update-flag endpoints were introduced as Options A and B (feat(api): add experimental feature flag update endpoints  #6305).
  2. The experimentation team added a new "key" attribute to identify multivariate options (feat(multivariate): add per-feature unique key to multivariate options #7698).
  3. The update-flag endpoints got full MV support (feat(__future__): Add MV capabilities to the experimental update-flag endpoints #7955).
  4. This PR adds the ability to use MV keys in the update-flag endpoints.

Changes

Contributes to #7642

Similarly to how a feature can be identified in the experimental update-flag endpoints, i.e. by either its ID or name, now we allow multivariate options to be identified by either their ID or [the new] key.

This means to make it easier to use update-flag, eliminating retrieving an MV ID as an extra step to achieving the use case of updating or re-weighting multivariates.

How did you test this code?

New tests.

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

vercel Bot commented Jul 13, 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 Jul 14, 2026 12:45am
flagsmith-frontend-preview Ignored Ignored Preview Jul 14, 2026 12:45am
flagsmith-frontend-staging Ignored Ignored Preview Jul 14, 2026 12:45am

Request Review

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: fc5bd214-f490-4501-985e-73f90eb96458

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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 feature New feature or request labels Jul 13, 2026
@emyller emyller marked this pull request as ready for review July 13, 2026 22:32
@emyller emyller requested review from a team as code owners July 13, 2026 22:32
@emyller emyller requested review from matthewelwell and removed request for a team July 13, 2026 22:32
@github-actions github-actions Bot added feature New feature or request and removed feature New feature or request labels Jul 13, 2026
@github-actions

github-actions Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Docker builds report

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

@emyller emyller requested a review from a team as a code owner July 13, 2026 22:37
@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 13, 2026
@github-actions

github-actions Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

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

passed  5 passed

Details

stats  5 tests across 3 suites
duration  39.4 seconds
commit  9e5c9cb
info  🔄 Run: #18218 (attempt 1)

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

passed  4 passed

Details

stats  4 tests across 3 suites
duration  45.8 seconds
commit  9e5c9cb
info  🔄 Run: #18218 (attempt 1)

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

passed  4 passed

Details

stats  4 tests across 3 suites
duration  40.4 seconds
commit  9e5c9cb
info  🔄 Run: #18218 (attempt 1)

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

passed  4 passed

Details

stats  4 tests across 4 suites
duration  1 minute, 1 second
commit  9e5c9cb
info  🔄 Run: #18218 (attempt 1)

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

passed  4 passed

Details

stats  4 tests across 3 suites
duration  45.6 seconds
commit  31389bf
info  🔄 Run: #18219 (attempt 1)

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

passed  4 passed

Details

stats  4 tests across 3 suites
duration  12.4 seconds
commit  31389bf
info  🔄 Run: #18219 (attempt 1)

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

passed  8 passed

Details

stats  8 tests across 6 suites
duration  1 minute, 14 seconds
commit  31389bf
info  🔄 Run: #18219 (attempt 1)

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

passed  1 passed

Details

stats  1 test across 1 suite
duration  1 minute, 2 seconds
commit  31389bf
info  🔄 Run: #18219 (attempt 1)

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

passed  4 passed

Details

stats  4 tests across 3 suites
duration  17.7 seconds
commit  0c2b855
info  🔄 Run: #18220 (attempt 1)

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

passed  4 passed

Details

stats  4 tests across 3 suites
duration  45.1 seconds
commit  0c2b855
info  🔄 Run: #18220 (attempt 1)

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

passed  5 passed

Details

stats  5 tests across 4 suites
duration  33.2 seconds
commit  0c2b855
info  🔄 Run: #18220 (attempt 1)

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

passed  5 passed

Details

stats  5 tests across 4 suites
duration  40.9 seconds
commit  0c2b855
info  🔄 Run: #18220 (attempt 1)

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

passed  4 passed

Details

stats  4 tests across 3 suites
duration  42.4 seconds
commit  541931c
info  🔄 Run: #18221 (attempt 1)

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

passed  4 passed

Details

stats  4 tests across 3 suites
duration  45.3 seconds
commit  541931c
info  🔄 Run: #18221 (attempt 1)

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

passed  3 passed

Details

stats  3 tests across 2 suites
duration  40.4 seconds
commit  541931c
info  🔄 Run: #18221 (attempt 1)

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

passed  5 passed

Details

stats  5 tests across 4 suites
duration  1 minute, 2 seconds
commit  541931c
info  🔄 Run: #18221 (attempt 1)

@github-actions

github-actions Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Visual Regression

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

@emyller emyller force-pushed the feat/update-flags-identify-mvs-by-key branch from 31389bf to 0c2b855 Compare July 13, 2026 22:41
@github-actions github-actions Bot added docs Documentation updates and removed feature New feature or request labels Jul 13, 2026
@github-actions github-actions Bot added feature New feature or request and removed docs Documentation updates labels Jul 13, 2026
@codecov

codecov Bot commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.64%. Comparing base (e75e61c) to head (541931c).

Additional details and impacted files
@@                           Coverage Diff                            @@
##           feat/multivariate-update-flag-endpoints    #8000   +/-   ##
========================================================================
  Coverage                                    98.64%   98.64%           
========================================================================
  Files                                         1498     1498           
  Lines                                        59410    59494   +84     
========================================================================
+ Hits                                         58604    58688   +84     
  Misses                                         806      806           

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

@emyller emyller force-pushed the feat/update-flags-identify-mvs-by-key branch from 0c2b855 to 541931c Compare July 14, 2026 00:45
@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 14, 2026
Comment on lines +244 to +280
def _validate_overrides_reweight_environment_options(
feature: Feature,
environment_multivariate_values: Sequence[EnvironmentMultivariateValuePayload],
override_multivariate_value_lists: Sequence[
Sequence[SegmentOverrideMultivariateValuePayload]
],
) -> None:
option_id_by_key: dict[str, int] = {
key: option_id
for key, option_id in feature.multivariate_options.filter(
key__isnull=False
).values_list("key", "id")
if key is not None
}
allowed_keys = {mv["key"] for mv in environment_multivariate_values if "key" in mv}
allowed_option_ids = {
mv["multivariate_feature_option"]
for mv in environment_multivariate_values
if "multivariate_feature_option" in mv
} | {option_id_by_key[key] for key in allowed_keys if key in option_id_by_key}
for multivariate_values in override_multivariate_value_lists:
for mv in multivariate_values:
if "multivariate_feature_option" in mv:
allowed = mv["multivariate_feature_option"] in allowed_option_ids
else:
allowed = (
mv["key"] in allowed_keys
or option_id_by_key.get(mv["key"]) in allowed_option_ids
)
if not allowed:
raise serializers.ValidationError(
{
"multivariate_feature_state_values": [
"Segment overrides can only re-weight existing variants."
]
}
)

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.

Can you explain why we need this together with _validate_multivariate_keys_exist?

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