@@ -38,6 +38,26 @@ def get_console() -> Console:
3838 return console
3939
4040
41+ def normalize_github_handle (github_handle : str ) -> str :
42+ """
43+ Normalize GitHub handle to lowercase for case-insensitive matching.
44+
45+ GitHub handles are case-insensitive but case-preserving. This function
46+ ensures consistent lookups in Firestore by normalizing to lowercase.
47+
48+ Parameters
49+ ----------
50+ github_handle : str
51+ GitHub handle in any case.
52+
53+ Returns
54+ -------
55+ str
56+ Normalized (lowercase) GitHub handle.
57+ """
58+ return github_handle .lower ()
59+
60+
4161def get_github_user () -> str | None :
4262 """
4363 Get GitHub username from environment variable.
@@ -145,7 +165,8 @@ def fetch_token_from_service( # noqa: PLR0911
145165 "Authorization" : f"Bearer { id_token } " ,
146166 "Content-Type" : "application/json" ,
147167 }
148- payload = {"github_handle" : github_handle }
168+ # Normalize GitHub handle for case-insensitive matching
169+ payload = {"github_handle" : normalize_github_handle (github_handle )}
149170
150171 response = requests .post (url , json = payload , headers = headers , timeout = 30 )
151172
@@ -292,7 +313,9 @@ def get_participant_data(
292313 Participant data or None if not found.
293314 """
294315 try :
295- doc_ref = db .collection ("participants" ).document (github_handle )
316+ # Normalize GitHub handle for case-insensitive matching
317+ github_handle_normalized = normalize_github_handle (github_handle )
318+ doc_ref = db .collection ("participants" ).document (github_handle_normalized )
296319 doc = doc_ref .get ()
297320
298321 if not doc .exists :
@@ -548,7 +571,9 @@ def check_onboarded_status(
548571 Tuple of (success, is_onboarded).
549572 """
550573 try :
551- doc_ref = db .collection ("participants" ).document (github_handle )
574+ # Normalize GitHub handle for case-insensitive matching
575+ github_handle_normalized = normalize_github_handle (github_handle )
576+ doc_ref = db .collection ("participants" ).document (github_handle_normalized )
552577 doc = doc_ref .get ()
553578
554579 if not doc .exists :
@@ -633,7 +658,9 @@ def update_onboarded_status(
633658 Tuple of (success, error_message).
634659 """
635660 try :
636- doc_ref = db .collection ("participants" ).document (github_handle )
661+ # Normalize GitHub handle for case-insensitive matching
662+ github_handle_normalized = normalize_github_handle (github_handle )
663+ doc_ref = db .collection ("participants" ).document (github_handle_normalized )
637664 doc_ref .update (
638665 {
639666 "onboarded" : True ,
0 commit comments