flagsmith
flagsmith copied to clipboard
Add concurrency check when updating flags config value
How are you running Flagsmith
- [ ] Self Hosted with Docker
- [ ] Self Hosted with Kubernetes
- [X] SaaS at flagsmith.com
- [ ] Some other way (add details in description below)
Describe the bug
When two people have the config drawer open for any given feature flag which includes config, if one user makes a change to the config value and then the second user makes a change (without refreshing the screen), the config value is updated with the second users change and the first change is lost.
Steps To Reproduce
- User 1 open right drawer with a feature flag and config
- Another user open same config value
- User 1 makes a change
- User 2 makes a different change
- User 1 change is lost
Expected behavior
Add an optomistic concurrency check (timestamp or concurrency key), and reject the 2nd change until the screen is reloaded and the user has the changes made between them loading the screen and wanting to save - they can then make the changes again to the latest data.
Screenshots
No response
This should be pretty easy to do in the FE by just checking the flag state id before saving the flag?
I'm not too clear on what you mean here @dabeeeenster, the ids would be the same? I guess what could happen is it could get the feature before saving and compare a last updated timestamp, though the correct behaviour for this scenario is not clear.
I wonder if this would naturally solved by feature flag versioning, with this we'd have a saved reference of each version. In the above scenario the user can compare versions, rollback or just combine the values.
User A updates a flag whilst user B is looking at the flag. We are versioning all this stuff, so we now have the original value v1 and new value v2 provided by User A.
When User B attempts to persist their change, we could have the FE check the latest version of the flag they are looking at. If they receive v1, they know they are not going to clobber any changes by other users. If they get v2, they know that someone else modified the value while they were looking at it. We can then surface an error/warning.
One possible UX to implement this is similar to VS Code does when a file has been externally modified: