aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKonstantin Ryabitsev <konstantin@linuxfoundation.org>2024-01-29 16:18:09 -0500
committerKonstantin Ryabitsev <konstantin@linuxfoundation.org>2024-01-29 16:18:09 -0500
commit8b26de088d25a3c2dee077bd721c0e8345284e7e (patch)
tree0ffc0505ac7a844763ae47e9825494f63d432734
parentc9b6a695ebb479970389819e5a269983e97a7535 (diff)
downloadb4-8b26de088d25a3c2dee077bd721c0e8345284e7e.tar.gz
pr: fix crash when GH pull request body is "None"
Using a dict.get() method doesn't work when the key is actually defined but set to None. In this case we have to actually check that it's a usable value. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
-rw-r--r--b4/pr.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/b4/pr.py b/b4/pr.py
index a4c195b..2d0ce23 100644
--- a/b4/pr.py
+++ b/b4/pr.py
@@ -385,7 +385,10 @@ def get_pr_from_github(ghurl: str) -> Optional[b4.LoreMessage]:
created_at = utils.format_datetime(datetime.strptime(prdata.get('created_at'), '%Y-%m-%dT%H:%M:%SZ'))
msg['Date'] = created_at
msg.set_charset('utf-8')
- msg.set_payload(prdata.get('body', '(no body)'), charset='utf-8')
+ body = prdata.get('body')
+ if not body:
+ body = ''
+ msg.set_payload(body, charset='utf-8')
lmsg = b4.LoreMessage(msg)
lmsg.pr_base_commit = base.get('sha')
lmsg.pr_repo = repo.get('clone_url')