Fix KeyError when HuggingFace user profile fields are missing (#20)

Handle optional fullname and email fields in user profile gracefully
using .get() method with fallback values to prevent KeyError when
uploading models to HuggingFace.

This fixes an issue where users without a public email or fullname
set in their HuggingFace profile would encounter an error during
the upload process.

Co-authored-by: ricyoung <riyoung@gmail.com>
This commit is contained in:
Richard Young, PhD
2025-11-18 16:02:50 -08:00
committed by GitHub
parent c8b6663b93
commit 13bb7b24d6
+3 -1
View File
@@ -421,8 +421,10 @@ def run():
continue continue
user = huggingface_hub.whoami(token) user = huggingface_hub.whoami(token)
fullname = user.get('fullname', user.get('name', 'Unknown'))
email = user.get('email', 'Not provided')
print( print(
f"Logged in as [bold]{user['fullname']} ({user['email']})[/]" f"Logged in as [bold]{fullname} ({email})[/]"
) )
repo_id = questionary.text( repo_id = questionary.text(