Skip to content

Commit 8b7b630

Browse files
committed
github-merge: Handle deleted users gracefully
Handle deleted github users gracefully when retrieving ACKs by replacing their name with `[deleted]` in the sanitization function. Tested with bitcoin/bitcoin#15423.
1 parent 7369af9 commit 8b7b630

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

github-merge.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,13 @@ def sanitize_ghdata(rec):
8585
rec['body'] = ''
8686
rec['body'] = sanitize(rec['body'], newlines=True)
8787

88-
# "Github username may only contain alphanumeric characters or hyphens'.
89-
# Use \Z instead of $ to not match final newline only end of string.
90-
if not re.match('[a-zA-Z0-9-]+\Z', rec['user']['login'], re.DOTALL):
91-
raise ValueError('Github username contains invalid characters: {}'.format(sanitize(rec['user']['login'])))
88+
if rec['user'] is None: # User deleted account
89+
rec['user'] = {'login': '[deleted]'}
90+
else:
91+
# "Github username may only contain alphanumeric characters or hyphens'.
92+
# Use \Z instead of $ to not match final newline only end of string.
93+
if not re.match('[a-zA-Z0-9-]+\Z', rec['user']['login'], re.DOTALL):
94+
raise ValueError('Github username contains invalid characters: {}'.format(sanitize(rec['user']['login'])))
9295
return rec
9396

9497
def retrieve_json(req_url, ghtoken, use_pagination=False):

0 commit comments

Comments
 (0)