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

API behavior between backends (may not be) consistent #45

Open
joemiller opened this issue Jun 1, 2019 · 2 comments
Open

API behavior between backends (may not be) consistent #45

joemiller opened this issue Jun 1, 2019 · 2 comments

Comments

@joemiller
Copy link
Contributor

Example on first-use of an application:

  • The macos keychain backend will return an empty list and nil error the first time Keys() (or Get()) is called:
2019/06/01 07:11:51 [keyring] Considering backends: [keychain pass file]
2019/06/01 07:11:51 [keyring] Querying keychain for service="vault", keychain=""
2019/06/01 07:11:51 [keyring] Found 0 results
$ echo $?
0
  • The libsecret backend will return a secretError with message that the keychain does not exist:
2019/06/01 07:13:25 [keyring] Considering backends: [secret-service kwallet pass file]
Error: Failed to read tokens from backend storage: The collection "vault" does not exist. Please add a key first
$ echo $?
255

The returned error is a generic type secretError and so I could handle this by wrapping keyring.List() and checking err.Error() contains the string "Please add a key first", but I am wondering what the expected behavior is for the library itself and if perhaps libsecret should be modified to not return an err if the collection does not yet exist?

I haven't checked the other backend types for how they handle first-use of Get and Keys yet.

@joemiller joemiller changed the title API behavior between backends is not consistent API behavior between backends (may not be) consistent Jun 1, 2019
@joemiller
Copy link
Contributor Author

kwallet backend behavior on initial Get() or List() is to create the wallet and return nil error

@lox
Copy link
Collaborator

lox commented Jun 7, 2019

Good question, I'd say Get() should return either the item or ErrKeyNotFound and List() should return a nil slice and no error if there are no keys.

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

No branches or pull requests

2 participants