1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-10-27 11:02:16 +01:00
unleash.unleash/src
Gastón Fournier bade23974e
feat: allow test operation for patch (#10736)
## About the changes
This would allow users to add test statements to protect from concurrent
modifications. From
https://github.com/orgs/Unleash/discussions/10707#discussioncomment-14602784

E.g.
If you had this feature flag configuration
```
{
  "name": "flexibleRollout",
  "constraints": [
    {
      "contextName": "a",
      "operator": "IN",
      "values": [
        "100", "200", "300", "400", "500"
      ],
      "caseInsensitive": false,
      "inverted": false
    }
  ],
  "parameters": {
    "rollout": "100",
    "stickiness": "default",
    "groupId": "api-access"
  },
  "variants": [],
  "segments": [
    122
  ],
  "disabled": false
}
```

And you'd like to remove the value 300 from the constraints, you'd have
to first get the current values and then PATCH the strategy with the
following body:
```
[{ "op": "remove", "path": "/constraints/0/values/2" }]
```

This could fail in case of concurrent modifications (e.g. if someone
removed the value "100", then the index to remove "300" will no longer
be 2).

With the test operation, you'd be able to add a protection mechanism to
validate that the value at index 2 is still 300:
```
[
    { "op": "test", "path": "/constraints/0/values/2", "value": "300" },
    { "op": "remove", "path": "/constraints/0/values/2" }
]
```
If the test fails, the remove operation will not be applied.

I've tested this locally and works as expected:
1. If the value is still 300, it will remove it
2. The operation will fail if the value is no longer 300 because of
another change.
2025-10-06 16:52:10 +02:00
..
lib feat: allow test operation for patch (#10736) 2025-10-06 16:52:10 +02:00
mailtemplates
migrations feat: milestone progressions migration (#10738) 2025-10-06 13:47:02 +02:00
test chore: return user id alongside max updated_at (#10732) 2025-10-06 11:43:40 +02:00
migrator.ts chore: remove AWS IAM DB auth prototype code (#10662) 2025-09-12 14:46:28 +01:00
server-dev.ts feat: add a suggestion banner at the bottom of empty feature-environments (#10725) 2025-10-06 09:02:15 +02:00
server.ts
test-setup.ts