Keys without any user IDs are not counted in import stats
Open, Needs TriagePublic

Assigned To
None
Authored By
• ikloecker
Thu, Oct 29, 11:30 AM

Description

If one retrieves a key from a keyserver and the keyserver serves a key without user ID then this is not reflected in the no_user_id count of the IMPORT_RES status message.

$ gpg --version
gpg (GnuPG) 2.5.25-beta29
libgcrypt 1.12.4

$ gpg --status-fd 2 --keyserver keys.openpgp.org --recv-keys 0xAEA84EDCF01AD86C4701C85C63113AE866587D0A
gpg: key 63113AE866587D0A: no user ID
gpg: Total number processed: 1
[GNUPG:] IMPORT_RES 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0
[GNUPG:] FAILURE gpg-exit 33554433

I think the correct status message would be

[GNUPG:] IMPORT_RES 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0

Accidental finding: The "General Error" failure reported on gpg-exit seems wrong. It doesn't happen with gnupg 2.2.55-beta7.

Event Timeline

Suggested fix:

From 3c4c37b98c13df1b0b4f2c72aa828e5c9c690580 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ingo=20Kl=C3=B6cker?= <dev@ingo-kloecker.de>
Date: Thu, 29 Oct 2026 11:30:22 +0100
Subject: [PATCH GnuPG] gpg: Update stats when importing a key without any user
 IDs

* g10/import.c (import_one_real): Increase no_user_id count if key has
no user IDs.
--

The counter is increased below if no user IDs are left after invalid
or to-be-ignored user IDs were removed. Hence it should also be
increased if the key doesn't have any user IDs in the first place which
is common nowadays for keys retrieved from keyservers.

GnuPG-bug-id: 8535
---
 g10/import.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/g10/import.c b/g10/import.c
index d0985c80d..1729dd64f 100644
--- a/g10/import.c
+++ b/g10/import.c
@@ -2051,6 +2051,7 @@ import_one_real (ctrl_t ctrl,
     {
       if (!silent)
         log_error( _("key %s: no user ID\n"), keystr_from_pk(pk));
+      stats->no_user_id++;
       if (!(options & IMPORT_DEBUG_ACCEPT_NO_UID))
         return 0;
     }
--
2.56.0