Skip to content

Commit bb6ba25

Browse files
committed
Fix parsing webhook events for issues closed as duplicate
1 parent 4ba9cdb commit bb6ba25

3 files changed

Lines changed: 11 additions & 1 deletion

File tree

github/api/types.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,7 @@ class IssueState(SerializableEnum):
330330
class IssueStateReason(SerializableEnum):
331331
COMPLETED = "completed"
332332
NOT_PLANNED = "not_planned"
333+
DUPLICATE = "duplicate"
333334

334335

335336
@dataclass

github/api/webhook.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import hashlib
1919
import hmac
2020
import json
21+
import logging
2122

2223
from aiohttp import web
2324
from attr import dataclass
@@ -57,13 +58,19 @@ class GitHubWebhookReceiver:
5758
handler: "HandlerFunc"
5859
secrets: "WebhookManager"
5960
global_secret: Optional[str]
61+
log: logging.Logger
6062

6163
def __init__(
62-
self, handler: "HandlerFunc", secrets: "WebhookManager", global_secret: Optional[str]
64+
self,
65+
handler: "HandlerFunc",
66+
secrets: "WebhookManager",
67+
global_secret: Optional[str],
68+
log: logging.Logger,
6369
) -> None:
6470
self.handler = handler
6571
self.secrets = secrets
6672
self.global_secret = global_secret
73+
self.log = log
6774

6875
@web_handler.post("/webhook")
6976
async def handle_global(self, request: web.Request) -> web.Response:
@@ -116,6 +123,7 @@ async def _handle(self, request: web.Request, webhook_info: "WebhookInfo") -> we
116123
try:
117124
event = type_class.deserialize(data)
118125
except SerializerError:
126+
self.log.exception("Failed to parse webhook event")
119127
return web.Response(status=500, text="Failed to parse event content")
120128
resp = await self.handler(event_type, event, delivery_id, webhook_info)
121129
if not isinstance(resp, web.Response):

github/bot.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ async def start(self) -> None:
5858
handler=self.webhook_handler,
5959
secrets=self.webhook_manager,
6060
global_secret=self.config["global_webhook_secret"],
61+
log=self.log.getChild("webhook_receiver"),
6162
)
6263
self.commands = Commands(bot=self)
6364

0 commit comments

Comments
 (0)