fix(keychain): clearer message for unsupported v2 keychain (#699)

macOS 26.4+ v2 keychains cannot be unlocked by password; drop the upstream WithKey advice the CLI has no flag for.
This commit is contained in:
Roger authored and GitHub committed 2026-11-17 14:41:54 +08:00
1 parent 806277e460
commit 8d1ff7355b
1 file changed
+6
+6
View File
@@ -17,6 +17,9 @@ var ErrLocked = errors.New("login keychain is locked")
var errNotFound = errors.New("not found in login keychain")
// errPasswordUnsupported replaces keychainbreaker's advice to pass a key with WithKey, which the CLI has no flag for.
var errPasswordUnsupported = errors.New("a password cannot unlock this keychain format (macOS 26.4 and later)")
type Keychain struct {
path string
password PasswordFunc
@@ -120,6 +123,9 @@ func (k *Keychain) unlock(ctx context.Context) error {
return ErrLocked
}
if err := k.opened.TryUnlock(keychainbreaker.WithPassword(password)); err != nil {
if errors.Is(err, keychainbreaker.ErrUnsupportedBlobVersion) {
err = errPasswordUnsupported
}
return fmt.Errorf("%w: %w", ErrLocked, err)
}
return nil