From 13bb7b24d64f26e50e69a76f6413ef19431542f6 Mon Sep 17 00:00:00 2001 From: "Richard Young, PhD" <753937+ricyoung@users.noreply.github.com> Date: Tue, 18 Nov 2025 16:02:50 -0800 Subject: [PATCH] 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 --- src/heretic/main.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/heretic/main.py b/src/heretic/main.py index a662ec6..169f138 100644 --- a/src/heretic/main.py +++ b/src/heretic/main.py @@ -421,8 +421,10 @@ def run(): continue user = huggingface_hub.whoami(token) + fullname = user.get('fullname', user.get('name', 'Unknown')) + email = user.get('email', 'Not provided') print( - f"Logged in as [bold]{user['fullname']} ({user['email']})[/]" + f"Logged in as [bold]{fullname} ({email})[/]" ) repo_id = questionary.text(