From 35772bad09117317a5de60acb7cfa855843a5e97 Mon Sep 17 00:00:00 2001 From: Mario Nebl Date: Thu, 3 Jul 2025 10:27:08 +0200 Subject: [PATCH 1/2] fix: guard against result.action being undefined I've observed the following recurring exception in handling `check_run` events. The stack trace indicates we're trying to read from `action` when it isn't defined. | This accepts potentially partial check messages instead of crashing the event processing. ``` TypeError: Cannot read properties of undefined (reading 'additions') ~~~~~ redacted ~~~~~ at Array.reduce () at _Settings.handleResults ( ~~~~~ redacted ~~~~~) ``` --- lib/settings.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/settings.js b/lib/settings.js index 20e71167..8d268fc9 100644 --- a/lib/settings.js +++ b/lib/settings.js @@ -245,8 +245,8 @@ ${this.results.reduce((x, y) => { if (y.type === 'ERROR') { error = true return `${x} - ❗ ${y.action.msg} ${y.plugin} ${prettify(y.repo)} ${prettify(y.action.additions)} ${prettify(y.action.deletions)} ${prettify(y.action.modifications)} ` - } else if (y.action.additions === null && y.action.deletions === null && y.action.modifications === null) { + ❗ ${y.action?.msg} ${y.plugin} ${prettify(y.repo)} ${prettify(y.action?.additions)} ${prettify(y.action?.deletions)} ${prettify(y.action?.modifications)} ` + } else if (y.action?.additions === null && y.action?.deletions === null && y.action?.modifications === null) { return `${x}` } else { if (y.action === undefined) { From 9a5ee8ba55bea6c653d0546f384092b0f1fe288f Mon Sep 17 00:00:00 2001 From: Mario Nebl Date: Mon, 7 Jul 2025 18:34:18 +0200 Subject: [PATCH 2/2] fix: ignore merge commits for file diffs Move from comparing the branch base against target to `pulls.listFiles`. This solves for a bug where updating a given command with changes from the target branch triggered the settings change detection. --- index.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index f6af26b5..ccc0e1e7 100644 --- a/index.js +++ b/index.js @@ -578,9 +578,23 @@ module.exports = (robot, { getRouter }, Settings = require('./lib/settings')) => if (check_suite.before === '0000000000000000000000000000000000000000') { check_suite.before = check_suite.pull_requests[0].base.sha } - params = Object.assign(context.repo(), { basehead: `${check_suite.before}...${check_suite.after}` }) - const changes = await context.octokit.repos.compareCommitsWithBasehead(params) - const files = changes.data.files.map(f => { return f.filename }) + params = Object.assign(context.repo(), { pull_number: pull_request.number, per_page: 100 }) + + const files = await context.octokit.paginate(context.octokit.pulls.listFiles, params, (response) => { + const files = new Set() + + for (const file of response.data) { + files.add(file.filename) + + if (file.previous_filename) { + files.add(file.previous_filename) + } + } + + return Array.from(files) + }) + + robot.log.debug('Files changed', { files }) const settingsModified = files.includes(Settings.FILE_PATH)