From 6ada35a20033e6701188cb7d32cc2facbb95093d Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Tue, 25 Jun 2024 15:05:32 +0200 Subject: [PATCH] [CHG] runbot_merge: ignore long comments Comments which are too long cause `logging` itself to crash, which kinda sucks. And long comments seem very unlikely to have anything for the mergebot to do besides. So just ignore them at intake. Limit is set to 5000 because there needs to be a limit somewhere and that's about the extent of it. --- runbot_merge/controllers/__init__.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/runbot_merge/controllers/__init__.py b/runbot_merge/controllers/__init__.py index 278b6609..1fb16fa1 100644 --- a/runbot_merge/controllers/__init__.py +++ b/runbot_merge/controllers/__init__.py @@ -386,6 +386,10 @@ def handle_comment(env, event): issue = event['issue']['number'] author = event['comment']['user']['login'] comment = event['comment']['body'] + if len(comment) > 5000: + _logger.warning('comment(%s): %s %s#%s => ignored (%d characters)', event['comment']['html_url'], author, repo, issue, len(comment)) + return "ignored: too big" + _logger.info('comment[%s]: %s %s#%s %r', event['action'], author, repo, issue, comment) if event['action'] != 'created': return "Ignored: action (%r) is not 'created'" % event['action'] @@ -397,6 +401,9 @@ def handle_review(env, event): pr = event['pull_request']['number'] author = event['review']['user']['login'] comment = event['review']['body'] or '' + if len(comment) > 5000: + _logger.warning('comment(%s): %s %s#%s => ignored (%d characters)', event['review']['html_url'], author, repo, pr, len(comment)) + return "ignored: too big" _logger.info('review[%s]: %s %s#%s %r', event['action'], author, repo, pr, comment) if event['action'] != 'submitted':