Skip to content

Commit 10e5cd5

Browse files
committed
Fix issue where PR without any description has its title edited
This came up in python/cpython#5291 The PR did not have any description, and the title was edited to include the bpo number. It caused a 500 error, because bedevere did not anticipate this situation. Updated the code so that it takes into consideration when the body is empty.
1 parent 229c1f1 commit 10e5cd5

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

bedevere/bpo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ async def set_status(event, gh, *args, **kwargs):
4343
else:
4444
if "body" in event.data["pull_request"]:
4545
body = event.data["pull_request"]["body"]
46-
if CLOSING_TAG not in body:
46+
if not body or CLOSING_TAG not in body:
4747
issue_number = issue_number_found.group("issue")
4848
new_body = BODY.format(body=body, issue_number=issue_number)
4949
body_data = {"body": new_body, "maintainer_can_modify": True}

tests/test_bpo.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,26 @@ async def test_edit_title():
109109
assert gh.data is not None
110110

111111

112+
@pytest.mark.asyncio
113+
async def test_no_body_when_edit_title():
114+
data = {
115+
"action": "edited",
116+
"pull_request": {
117+
"url": "https://api.github.com/repos/python/cpython/pulls/5291",
118+
"title": "bpo-32636: Fix @asyncio.coroutine debug mode bug",
119+
"body": None,
120+
"statuses_url": "https://api.github.com/repos/python/cpython/statuses/98d60953c85df9f0f28e04322a4c4ebec7b180f4",
121+
},
122+
"changes": {
123+
"title": "bpo-32636: Fix @asyncio.coroutine debug mode bug exposed by #5250."
124+
},
125+
}
126+
event = sansio.Event(data, event="pull_request", delivery_id="12345")
127+
gh = FakeGH()
128+
await bpo.router.dispatch(event, gh)
129+
assert gh.data is not None
130+
131+
112132
@pytest.mark.asyncio
113133
async def test_edit_other_than_title():
114134
data = {

0 commit comments

Comments
 (0)