Skip to content

Make segment change requests work #5768

@emyller

Description

@emyller

Change Requests are currently only used to propose changes to feature flags. We also want to allow users to propose changes to segment rules, i.e. segment change requests — sometimes referred to as project change requests, due to the segment change request belonging to a project rather than an environment, such is the case of feature change requests.

Well actually, the feature already exists, but it's not yet live because the code can't make reference of previous rules and conditions for diffing purposes. A pull request was submitted to help solve that problem, though we decided to revisit the whole implementation and make fundamental changes to avoid performance and consistency pitfalls — to be documented as sub issues of this epic.

The journey as of this writing:

Merged What Pull request
2024-10-22 Segment-specific logic was moved to flagsmith-common. Flagsmith/flagsmith-common#4
2024-11-21 Change Requests now imports from flagsmith-common to manage segments. https://github.com/Flagsmith/flagsmith-workflows/pull/39
2024-11-21 Core API implements segment change requests. #4265
Open Frontend for segment change requests. It's hidden under the FoF flag segment_change_requests and should be merged when the backend is working. #4852

There was an ongoing effort to enable comparing each rule and condition of a draft segment — i.e. the segment revision being proposed in a change request — against the live segment. Relevant work:

Merged What Pull request
2025-01-27 Prepares rules and condition serializers for the new reference field added to the models. Flagsmith/flagsmith-common#11
Open Adds the new reference field to the models, and implements an algorithm to match a segment revision's rules and conditions to the live segment in order to populate the reference field. #4988
Open Closes the loop by calling the above algorithm from the Change Request context. https://github.com/Flagsmith/flagsmith-workflows/pull/63

The following diagram illustrates the functionality flow in use cases “Create a Segment Change Request” and “Commit a Segment Change Request”. It presents the architecture and some of the relevant components from the work listed above:

Image

In this epic, we're aiming to simplify the above architecture with this foundational principle:

🏁 Instead of:

Cloning the live segment into a draft with unreferenced rules and conditions, and later match live rules and conditions to create/update references,

We will:

Create a brand new segment with rules and conditions already pointing to their live counterparts.

Here's an overview of what we want to achieve:

Image

The necessary ground work for achieving this goal, as well as the side effects of its changes, are in this epic's sub issues.

Sub-issues

Metadata

Metadata

Assignees

Labels

apiIssue related to the REST API

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions