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

fix nav-to-nearest mixin when there are no ancestors #6198

Merged
merged 1 commit into from
Feb 9, 2019

Conversation

meirish
Copy link
Contributor

@meirish meirish commented Feb 8, 2019

The mixin that was added to navigate to the nearest existing secret when you deleted a secret didn't properly handle the case when a secret was at the top level.

In practice this means that a secret at secrets/foo, when deleted via the UI, would be deleted, but the redirection would result in an uncaught error and it would look like nothing happened when you tried to delete the secret.

This fixes the issue with the redirect erroring.
Fixes #6197

@meirish meirish added this to the 1.0.3 milestone Feb 8, 2019
@meirish meirish requested review from a team February 8, 2019 23:24
Copy link
Contributor

@andaley andaley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assuming this fix applies to kvv2, approved!

@meirish meirish merged commit b16527d into master Feb 9, 2019
@@ -15,7 +15,7 @@ export default Mixin.create({
navToNearestAncestor: task(function*(key) {
let ancestors = utils.ancestorKeysForKey(key);
let errored = false;
let nearest = ancestors.pop();
let nearest = ancestors && ancestors.pop();
Copy link

@johncowen johncowen Feb 11, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey 👋

Just a little observation/suggestion here. I'm not even sure this is possible as I don't know how else you are using utils.ancestorKeysForKey.

Theoretically you could have this bug happening anywhere you are using utils.ancestorKeysForKey just it's not been noticed it yet, but you've only added the ancestors truthy check here.

Ideally, (although I'm not sure if its possible, and would be a bigger/riskier change). If utils.ancestorKeysForKey returned an empty array instead of null where there are no 'ancestorKeys', then your while here would still not run ([].pop() === undefined)

I just had a quick look to see where else you are using this method:

screenshot 2019-02-11 at 09 52 16

In namespace-picker you switch a null result back to an empty array anyway, and in key-value-header you do another truthy check on the return value which you could switch to a length check (Q: How many ancestors are there for this key? A: Zero)

So this is possible I 'think' (as long as my search picked up all places you are using this) and it's probably not that risky to do either and doing this would prevent any further bugs like this slipping in in the future.

TLDR; is You'd be changing it so the method would always return an array (no alarms and no surprises), not 'mostly an array, but sometimes null'.

Anyway, I just had a peek here whilst drinking my morning tea, thought you might like that ^ - no matter if not.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing this out - been waayyy too long since I've looked at the util code and took a wider view of its usage. I made the necessary changes / cleanup in #6205

@meirish meirish deleted the b-ui-top-level-keys branch February 11, 2019 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UI - kv v2 permanent delete doesn't work
3 participants