Skip to content
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

Closed
389-ds-bot opened this issue Sep 13, 2020 · 12 comments
Closed
Labels
merged Migration flag - PR pr Migration flag - PR

Comments

@389-ds-bot
Copy link

389-ds-bot commented Sep 13, 2020

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: ???

@389-ds-bot 389-ds-bot added merged Migration flag - PR pr Migration flag - PR labels Sep 13, 2020
@389-ds-bot
Copy link
Author

Comment from mhonek (@kenoh) at 2019-02-26 13:58:16

Should default to None as we really don't know (and will never know if it doesn't). False brings a false impression of "we know it does not".

@389-ds-bot
Copy link
Author

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 exists = None). And we should put here exists = None for clarity.

@389-ds-bot
Copy link
Author

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 self._change_identity(new_dn=...), that clearly says it all.

@389-ds-bot
Copy link
Author

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.

@389-ds-bot
Copy link
Author

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).

@389-ds-bot
Copy link
Author

Comment from firstyear (@Firstyear) at 2019-02-27 00:20:02

default to None:

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.

This may happen if we have no access

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).

Do we need a comment.

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.

AssertionError

Yeah, that probably reasonable to change.

@389-ds-bot
Copy link
Author

Comment from firstyear (@Firstyear) at 2019-02-27 01:31:14

rebased onto 559e7ddb1837e51eceaee54b1c5ecd107cb00425

@389-ds-bot
Copy link
Author

Comment from firstyear (@Firstyear) at 2019-02-27 10:26:29

rebased onto 12dcdbb4aab7d3cb086dd37d9fa1747b6535d9dd

@389-ds-bot
Copy link
Author

Comment from spichugi (@droideck) at 2019-03-07 21:45:41

LGTM

@389-ds-bot
Copy link
Author

Comment from firstyear (@Firstyear) at 2019-03-08 03:13:26

rebased onto 28fe160

@389-ds-bot
Copy link
Author

Comment from firstyear (@Firstyear) at 2019-03-08 03:13:58

Pull-Request has been merged by Firstyear

@389-ds-bot
Copy link
Author

Patch
50245.patch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged Migration flag - PR pr Migration flag - PR
Projects
None yet
Development

No branches or pull requests

1 participant