Skip to content

Commit f81349f

Browse files
committed
store/keychain: comment why we don't error on id parse in filter
Signed-off-by: Alano Terblanche <18033717+Benehiko@users.noreply.github.com>
1 parent 88e0c93 commit f81349f

3 files changed

Lines changed: 18 additions & 0 deletions

File tree

store/keychain/keychain_darwin.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,12 @@ func (k *keychainStore[T]) Filter(_ context.Context, pattern store.Pattern) (map
200200

201201
creds := make(map[string]store.Secret)
202202
for _, result := range results {
203+
// it is possible that someone else has stored secrets in the keychain
204+
// directly without conforming to the store.ID format.
205+
// We shouldn't error here when these values cannot be retrieved or
206+
// parsed. Instead we just ignore them and proceed.
207+
// I guess in future we could at least log them somewhere?
208+
// but for now, let's just continue with the other items in the store.
203209
id, err := store.ParseID(result.Account)
204210
if err != nil {
205211
continue

store/keychain/keychain_linux.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,12 @@ func (k *keychainStore[T]) Filter(_ context.Context, pattern store.Pattern) (map
368368
return nil, err
369369
}
370370

371+
// it is possible that someone else has stored secrets in the keychain
372+
// directly without conforming to the store.ID format.
373+
// We shouldn't error here when these values cannot be retrieved or
374+
// parsed. Instead we just ignore them and proceed.
375+
// I guess in future we could at least log them somewhere?
376+
// but for now, let's just continue with the other items in the store.
371377
attrID, ok := attributes["id"]
372378
if !ok {
373379
continue

store/keychain/keychain_windows.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,12 @@ func (k *keychainStore[T]) Filter(_ context.Context, pattern store.Pattern) (map
210210

211211
secrets := make(map[string]store.Secret)
212212
for cred := range findServiceCredentials(k, pattern, credentials) {
213+
// it is possible that someone else has stored secrets in the keychain
214+
// directly without conforming to the store.ID format.
215+
// We shouldn't error here when these values cannot be retrieved or
216+
// parsed. Instead we just ignore them and proceed.
217+
// I guess in future we could at least log them somewhere?
218+
// but for now, let's just continue with the other items in the store.
213219
id, err := store.ParseID(strings.ReplaceAll(cred.TargetName, onlyLabelPrefix, ""))
214220
if err != nil {
215221
continue

0 commit comments

Comments
 (0)