macOS: denied keychain prompt on delete raises PasswordDeleteError instead of KeyringLocked

Open Beginner friendly
#772 0 comments 0 reactions 0 assignees View on GitHub

@r3wretrhy is already working on this.

Since Oct 1, 2026.

  • #773 by @r3wretrhy — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
86/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
macos, python
Domain
backend, security

Research direction

Start in keyring/backends/macOS/init.py and compare delete_password with the existing get_password and set_password handling of api.KeychainDenied. Verify that a denied delete raises KeyringLocked while api.NotFound and other api.Error cases still raise PasswordDeleteError; the issue does not name a test file.

Written by the indexing model from the issue text.

Description

Since #375, the macOS backend maps api.KeychainDenied (errSecUserCanceled, -128) to KeyringLocked in get_password and set_password. delete_password does not: it turns every api.Error into PasswordDeleteError, the same exception it raises for an item that does not exist (api.NotFound).

So a caller cannot tell "the user denied access, the secret is still there" from "nothing to delete". Code that treats PasswordDeleteError as "already gone" (a reasonable reading, since that is what SecretService and Windows raise for a missing entry) reports a successful delete while the secret stays in the keychain.

Suggested fix, in line with the other two methods:

except api.KeychainDenied as e:
    raise KeyringLocked(f"Can't delete password in keychain: {e}") from e
except api.Error as e:
    raise PasswordDeleteError(f"Can't delete password in keychain: {e}") from e

Found by reading keyring/backends/macOS/__init__.py on main (7603e7c); not reproduced interactively.

Dominant language
Python
Stars
1.5k
Forks
208
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from jaraco/keyring

All issues in jaraco/keyring

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.