Skip to content

Commit 9a4f76f

Browse files
committed
Add further debugging when importing a particular OpenPGP key
1 parent 5c8850f commit 9a4f76f

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

scripts/keys_import.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def print_and_flush(message: str) -> None:
5050
sys.stdout.flush()
5151

5252

53-
def log_target_key_debug(outcomes, committee_name: str) -> None:
53+
def log_target_key_debug(outcomes, committee_name: str, email_to_uid: dict[str, str]) -> None: # noqa: C901
5454
target = TARGET_FINGERPRINT.lower()
5555
for result in outcomes.results():
5656
key_model = result.key_model
@@ -61,6 +61,22 @@ def log_target_key_debug(outcomes, committee_name: str) -> None:
6161
f"apache_uid={key_model.apache_uid} primary_uid={key_model.primary_declared_uid} "
6262
f"secondary_uids={key_model.secondary_declared_uids}"
6363
)
64+
uids: list[str] = []
65+
if key_model.primary_declared_uid:
66+
uids.append(key_model.primary_declared_uid)
67+
if key_model.secondary_declared_uids:
68+
uids.extend(key_model.secondary_declared_uids)
69+
for uid_value in uids:
70+
email = util.email_from_uid(uid_value)
71+
ldap_uid = email_to_uid.get(email) if email else None
72+
mapped = None
73+
if email and email.endswith("@apache.org"):
74+
mapped = email.removesuffix("@apache.org")
75+
elif ldap_uid:
76+
mapped = ldap_uid
77+
print_and_flush(
78+
f"DEBUG uid={uid_value} extracted_email={email} ldap_uid={ldap_uid} mapped_uid={mapped}"
79+
)
6480
for error in outcomes.errors():
6581
fingerprint = None
6682
apache_uid = None
@@ -145,7 +161,7 @@ async def keys_import(conf: config.AppConfig, asf_uid: str) -> None:
145161
wafa = write.as_foundation_admin(committee_name)
146162
keys_file_text = content.decode("utf-8", errors="replace")
147163
outcomes = await wafa.keys.ensure_associated(keys_file_text)
148-
log_target_key_debug(outcomes, committee_name)
164+
log_target_key_debug(outcomes, committee_name, email_to_uid)
149165
yes = outcomes.result_count
150166
no = outcomes.error_count
151167
if no:

0 commit comments

Comments
 (0)