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
PR - Ticket 50137 - create should not check in non-stateful mode for exist #3304
Comments
Comment from mhonek (@kenoh) at 2019-02-26 13:58:16 Should default to |
Comment from mhonek (@kenoh) at 2019-02-26 14:00:39 This may happen even if we have no access, if I am not mistaken, no only if it is not there (which is why we should default to |
Comment from mhonek (@kenoh) at 2019-02-26 14:12:20 Is there really need for a comment here? If it is not clear what we're doing on the next line (and we're doing this at couple of places around) then we should make a method, like |
Comment from mhonek (@kenoh) at 2019-02-26 14:21:13 I'd probably go with AssertionError in this case as it is more accurate than a general exception. |
Comment from mhonek (@kenoh) at 2019-02-26 14:32:00 Do we also really need the two four-line comment blocks? I believe the conditional structure is clear enough to get the idea even without them. They may eventually become misleading when the code around changes, especially because they refer to other parts of the function (even the function itself) which they are not close enough to. Anyways, functionally this looks good to me (except for the case of insufficient privileges I mentioned above - we'd have to handle it more complexly, but so far so good). |
Comment from firstyear (@Firstyear) at 2019-02-27 00:20:02
No, because now we have a TERNARY state. None, False, or True. Then we set True/False if Exist, and None is if not exist. Now we have more states and possibilities of failure if someone changes this later. The behavior is correct - if false, we assume it's not there and try to create which is the behaviour that is requested.
No, this only happens if someone royally messes up and manages to change the function in such a way that allows ensure mode == False, and exists True. This means that the if condition around the test of existance has broken, and has led to an invalid state. If we took your "= None" procedure, we still need to test for this state anyway, which is why I won't add exists= None because it's a state that doesn't matter and doesn't add any value (only complexity).
Yes. We absolutely need comments. Code is hard to read and follow, and there is extra context in the comment that the code doesn't allude to, it makes it easier to communicate. It discusses reasons that the code doesn't highlight. I will never comment my code "less", because william of the future is an idiot and needs the help.
Yeah, that probably reasonable to change. |
Comment from firstyear (@Firstyear) at 2019-02-27 01:31:14 rebased onto 559e7ddb1837e51eceaee54b1c5ecd107cb00425 |
Comment from firstyear (@Firstyear) at 2019-02-27 10:26:29 rebased onto 12dcdbb4aab7d3cb086dd37d9fa1747b6535d9dd |
Comment from spichugi (@droideck) at 2019-03-07 21:45:41 LGTM |
Comment from firstyear (@Firstyear) at 2019-03-08 03:13:26 rebased onto 28fe160 |
Comment from firstyear (@Firstyear) at 2019-03-08 03:13:58 Pull-Request has been merged by Firstyear |
Patch |
Cloned from Pagure Pull-Request: https://pagure.io/389-ds-base/pull-request/50245
Bug Description: In def create, we should do a existance check for an
entry before creating. However, depending on access control this may not
work as intended because you can create without sight of the target, and
then this may cause misleading exceptions preventing the create.
Fix Description: In stateless mode, don't check the existance of the
entry before create.
In stateful ensure mode, continue to check for the existance.
Resolves: #3196
Author: William Brown william@blackhats.net.au
Review by: ???
The text was updated successfully, but these errors were encountered: