Skip to content

feat(__future__): Experimental update-flag - #8102

Merged
emyller merged 40 commits into
mainfrom
feat/update-flag-option-c
Aug 14, 2026
Merged

feat(__future__): Experimental update-flag#8102
emyller merged 40 commits into
mainfrom
feat/update-flag-option-c

Conversation

@emyller

@emyller emyller commented Jul 25, 2026

Copy link
Copy Markdown
Contributor
  • 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
Closes #8088

Stabilises experimental update-flag endpoints to one option, still experimental. It supports the verbs PATCH and PUT.

  • Avoids touching Options A + B — cleanup + interface migration issue will follow.
  • Includes multivariate flag support.
  • Improves API and module design.

Updated documentation: https://docs-git-feat-update-flag-option-c-flagsmith.vercel.app/managing-flags/updating-flags

How did you test this code?

Integration tests included.

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

vercel Bot commented Jul 25, 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 Aug 14, 2026 9:07pm
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
flagsmith-frontend-preview Ignored Ignored Preview Aug 14, 2026 9:07pm
flagsmith-frontend-staging Ignored Ignored Preview Aug 14, 2026 9:07pm

Request Review

@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Added an experimental future API for reading and updating feature flags. The API supports PATCH and PUT operations for environment defaults, segment overrides, variant allocations, replacement behaviour, permissions, workflow rejection, version publication, audit logging, and structured events. Added serializers, typed schemas, response mappers, integration tests, OpenAPI schemas, and documentation. Shared feature value mappings now support API serialisation.

Estimated code review effort: 5 (Critical) | ~120 minutes

Merge Risk: 🟠 High · up to 4bd15

This PR adds new flag-update behavior, but the current implementation can expose internal validation details and persist incorrect flag configuration when duplicate variants or conflicting segment priorities are submitted. These security and correctness risks should be fixed before merging; documentation and error-reporting issues also remain for follow-up.


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 api Issue related to the REST API docs Documentation updates feature New feature or request and removed docs Documentation updates labels Jul 25, 2026

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

Looks good overall. My main gripe is combining full-replace and delete: true semantics for lists of different entities in a single API.

Comment thread docs/docs/managing-flags/updating-flags.md Outdated
Comment thread docs/docs/managing-flags/updating-flags.md Outdated
Comment thread docs/docs/managing-flags/updating-flags.md Outdated
Comment thread docs/docs/managing-flags/updating-flags.md Outdated
Comment thread docs/docs/managing-flags/updating-flags.md Outdated
Comment thread docs/docs/managing-flags/updating-flags.md Outdated
Comment thread docs/docs/managing-flags/updating-flags.md Outdated
Comment thread docs/docs/managing-flags/updating-flags.md Outdated
Comment thread docs/docs/managing-flags/updating-flags.md Outdated
@emyller
emyller force-pushed the feat/update-flag-option-c branch from 2b9f91b to 4593ce3 Compare August 3, 2026 22:43
@github-actions github-actions Bot added the docs Documentation updates label Aug 3, 2026
@github-actions github-actions Bot added feature New feature or request and removed feature New feature or request docs Documentation updates labels Aug 3, 2026
@emyller
emyller force-pushed the feat/update-flag-option-c branch from 4593ce3 to ff05fcf Compare August 4, 2026 00:17
@github-actions github-actions Bot added the docs Documentation updates label Aug 4, 2026
@github-actions github-actions Bot added feature New feature or request docs Documentation updates and removed feature New feature or request docs Documentation updates labels Aug 4, 2026
@emyller
emyller force-pushed the feat/update-flag-option-c branch from c17e1a8 to 468a299 Compare August 4, 2026 00:22
@github-actions github-actions Bot removed feature New feature or request docs Documentation updates labels Aug 4, 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: 9


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 6fbf2c9d-7753-420e-8ab4-93a8a84bfcfb

📥 Commits

Reviewing files that changed from the base of the PR and between 14e860c and c8de0cd.

📒 Files selected for processing (21)
  • api/api/urls/future.py
  • api/app/urls.py
  • api/experimentation/services.py
  • api/features/feature_states/models.py
  • api/features/future/__init__.py
  • api/features/future/exceptions.py
  • api/features/future/mappers.py
  • api/features/future/permissions.py
  • api/features/future/serializers.py
  • api/features/future/services.py
  • api/features/future/types.py
  • api/features/future/views.py
  • api/tests/integration/conftest.py
  • api/tests/integration/environments/identities/test_integration_identities.py
  • api/tests/integration/features/future/__init__.py
  • api/tests/integration/features/future/test_update_flag_endpoint.py
  • api/tests/integration/helpers.py
  • docs/docs/deployment-self-hosting/observability/_events-catalogue.md
  • docs/docs/integrating-with-flagsmith/flagsmith-api-overview/admin-api/updating-flags.md
  • docs/docs/managing-flags/feature-versioning.md
  • docs/docs/managing-flags/updating-flags.md
💤 Files with no reviewable changes (1)
  • docs/docs/integrating-with-flagsmith/flagsmith-api-overview/admin-api/updating-flags.md

Comment thread api/features/future/permissions.py
Comment thread api/features/future/serializers.py Outdated
Comment thread api/features/future/services.py
Comment thread api/features/future/views.py Outdated
Comment thread api/tests/integration/conftest.py
Comment thread api/tests/integration/features/future/test_flag_endpoint.py Outdated
Comment thread docs/docs/managing-flags/feature-versioning.md Outdated
Comment thread docs/docs/managing-flags/updating-flags.md Outdated

@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: 1

Caution

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

⚠️ Outside diff range comments (3)
api/features/future/mappers.py (1)

14-23: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Explain the arg-type ignore.

The ignore at Line 18 suppresses Mypy without stating the local type invariant. Add a short explanation, or remove the ignore if the shared mapping already satisfies the response type. (raw.githubusercontent.com)

Based on learnings, API typing workarounds should use precise Mypy ignores with a short explanation so obsolete ignores can be removed.

Source: Learnings

api/features/future/serializers.py (1)

53-65: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Reject duplicate variant IDs.

given_ids is a set, so duplicate IDs disappear before the membership checks. _write_variants then processes the same option more than once. The request can pass validation but persist a different allocation from the validated weights. (raw.githubusercontent.com)

Check that the number of unique IDs equals the number of variants.

Proposed validation
         given_ids = {variant["id"] for variant in variants}
+        if len(given_ids) != len(variants):
+            raise serializers.ValidationError("Duplicate variant.")
api/features/future/services.py (1)

281-287: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add coverage for API-key publication.

This branch passes author.key to published_by_api_key, which is different from the FFAdminUser path. Add a v2-versioned integration test with a master API key and assert the published version author fields. (raw.githubusercontent.com)


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 3c19b85e-9abf-44da-9f91-025e013ac74a

📥 Commits

Reviewing files that changed from the base of the PR and between 59dca48 and 348f5a9.

📒 Files selected for processing (6)
  • api/features/future/mappers.py
  • api/features/future/serializers.py
  • api/features/future/services.py
  • api/features/future/views.py
  • docs/docs/deployment-self-hosting/observability/_events-catalogue.md
  • docs/docs/managing-flags/updating-flags.md

Comment thread docs/docs/managing-flags/updating-flags.md Outdated
@codecov

codecov Bot commented Aug 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.78%. Comparing base (14e860c) to head (27dcc94).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8102      +/-   ##
==========================================
+ Coverage   98.76%   98.78%   +0.01%     
==========================================
  Files        1594     1604      +10     
  Lines       63657    64335     +678     
==========================================
+ Hits        62873    63551     +678     
  Misses        784      784              

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

Comment thread api/features/future/serializers.py Dismissed

@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: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 5e946651-e419-4d0f-8c68-651c721bf754

📥 Commits

Reviewing files that changed from the base of the PR and between e5fc0fa and 4bd15ed.

📒 Files selected for processing (1)
  • api/features/future/serializers.py

Comment thread api/features/future/serializers.py

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

Some comments to resolve before I approve.

Comment thread api/features/future/services.py
Comment thread api/features/future/serializers.py
Comment thread api/features/future/services.py
Comment thread api/api/urls/future.py Outdated
Comment thread docs/docs/managing-flags/updating-flags.md
Comment thread api/features/future/services.py
Comment thread api/features/future/exceptions.py Outdated
Comment thread api/features/future/serializers.py
Comment thread api/features/future/services.py

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

Great work 🙌

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.

update-flag endpoint needs a stable API

6 participants