Skip to content

chore(apt): remove unused apt key listing code - #7113

Open
wak327 wants to merge 1 commit into
canonical:mainfrom
wak327:chore/remove-unused-apt-key-list
Open

wak327 wants to merge 1 commit into
canonical:mainfrom
wak327:chore/remove-unused-apt-key-list

Conversation

@wak327

@wak327 wak327 commented Sep 29, 2026 •

Copy link
Copy Markdown

Proposed Commit Message

chore(apt): remove unused apt key listing code

apt_key() implemented 'list' and 'finger' commands next to 'add', but
nothing calls them: add_apt_key_raw() is the only caller of apt_key()
and it only ever adds keys. Rather than fix the listing logic, which
assumes every file under /etc/apt/trusted.gpg.d/ is a keyring, drop it
together with GPG.list_keys(), which only existed to serve it.

Fixes GH-5333

Additional Context

Fixes #5333

This follows the suggestion in GH-5333 to delete the code rather than fix it. The only call site of apt_key() passes "add", and nothing else uses GPG.list_keys(). APT_LOCAL_KEYS stays because tests/integration_tests/modules/test_apt_functionality.py still uses it.

apt_key() now raises ValueError for any command other than "add", and a new test covers this. test_kill_gpg_succeeds only called list_keys() to "start" gpg, so it now calls dearmor() for that instead.

Verified with the pinned black, isort, ruff, pylint and mypy, and the full unit suite passes (5,775 tests).

Test Steps

tox -e py3 -- tests/unittests/config/test_apt_key.py tests/unittests/test_gpg.py tests/unittests/config/

Merge type

  • Squash merge using "Proposed Commit Message"
  • Rebase and merge unique commits. Requires commit messages per-commit each referencing the pull request number (#<PR_NUM>)

apt_key() implemented 'list' and 'finger' commands next to 'add', but
nothing calls them: add_apt_key_raw() is the only caller of apt_key()
and it only ever adds keys. Rather than fix the listing logic, which
assumes every file under /etc/apt/trusted.gpg.d/ is a keyring, drop it
together with GPG.list_keys(), which only existed to serve it.

Fixes canonicalGH-5333
@wak327
wak327 force-pushed the chore/remove-unused-apt-key-list branch from 19caaf7 to f2a3348 Compare September 30, 2026 20:10
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

Successfully merging this pull request may close these issues.

Listing apt keys doesn't work after apt-file deprecation

1 participant