Skip to content
This repository has been archived by the owner on Jul 21, 2021. It is now read-only.

Exists api return true but path does not exist #236

Open
aluode99 opened this issue Apr 2, 2020 · 3 comments
Open

Exists api return true but path does not exist #236

aluode99 opened this issue Apr 2, 2020 · 3 comments

Comments

@aluode99
Copy link

aluode99 commented Apr 2, 2020

using Exists api return true when non-ErrNoNode occurs.

_, err := c.request(opExists, &existsRequest{Path: path, Watch: false}, res, nil)
exists := true
if err == ErrNoNode {
exists = false
err = nil
}
return exists, &res.Stat, err

@jasonjoo2010
Copy link

We use Get() instead of Exists() because Exists() doesn't work correctly either for us.

@jasonjoo2010
Copy link

jasonjoo2010 commented Jun 4, 2020

And maybe i know the direct reason (not the real reason) is that we cannot do comparison like below in our own logic:

err == ErrNoNode

Instead, we do

err.Error() == ErrNoNode.Error()

Maybe they are not reused correctly inside though there was a error code map in constants.go

@ajpetersons
Copy link

You should ignore all other return values in case non-nil error is returned. The exists return value carries no meaning if an error was present

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants