-
Notifications
You must be signed in to change notification settings - Fork 50
Rejecting updates without a version #36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
should not be difficult to implement, I do not have time to make proper tests, anyway take a look at concurrency.core._select_lock() at line 44. value should be None (or 0 if first save). |
+1 Just ran into this issue. A pre-concurrency UI was sending REST requests without a version; no errors were generated and data was overwritten. It seems like a pretty serious bug if you can defeat the entire system through omission. This strikes me as so serious that I'd recommend a major version change to make the opposite behavior "default". If you insist on persisting a very dangerous condition in the name of backwards compatibility, maybe a setting to override the default? |
Turns out I had an issue at two different levels:
I've submitted a ticket at DRF and worked around this issue in my local copy. The logical fix from the perspective of the REST framework was to, at minimum, use the default value (if available) for any value absent in the PUT. The default for these fields is
I'm about to submit a PR that:
I also had to account for an edge case (documented inline) that can occur during a create. This required a change in the way the logic flowed. I added a test that failed under the old code. All of the old tests pass except one. As I'll reiterate in the PR, I'm not clear why the test should fail to fix the code. If you can explain, I'll update the PR accordingly. |
* pull-requests/66: update CHANGES tox.ini: do not install postgis if not required update docs - Document new setting - Fix loaddata test to pass without disabling concurrency - Remove loaddata test that disable concurrency (now redundant) - fixes #36
* release/1.3: bump v1.3 update CHANGES tox.ini: do not install postgis if not required update docs - Document new setting - Fix loaddata test to pass without disabling concurrency - Remove loaddata test that disable concurrency (now redundant) - fixes #36 add default value to ConcurrencyOptions.initial add explicit mention to MIT license open 1.3 alpha
I haven't looked into the internals to see if this is difficult or even possible - but I'd like to start a discussion on the subject.
I'd like to be able to raise an exception if a versioned instance is modified without supplying a version value. This would close a loophole where there is some method or API call that I've forgotten to update to handle concurrency checks.
Our use case is a large complex codebase where we want to quickly add baseline protection against concurrent updates - a strict 'fail fast' in any situation where there is a potential for conflicts.
The text was updated successfully, but these errors were encountered: