From 374dc294e35607ab1570a5780bc2183d3159d296 Mon Sep 17 00:00:00 2001 From: "github-agentic-autofix[bot]" <314318003+GitHub Agentic Autofix@users.noreply.github.com> Date: Thu, 12 Nov 2026 16:25:32 +0000 Subject: [PATCH 1/4] Initial plan From c6a7b776b912199c87099eccb3aa9e4b78cd97ef Mon Sep 17 00:00:00 2001 From: "github-agentic-autofix[bot]" <314318003+GitHub Agentic Autofix@users.noreply.github.com> Date: Thu, 12 Nov 2026 16:28:14 +0000 Subject: [PATCH 2/4] Handle incomplete survey responses safely Co-authored-by: mageroni <107436170+mageroni@users.noreply.github.com> --- index.js | 7 ++++--- test/index.test.js | 11 +++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index ee62c28..eb3d0b9 100644 --- a/index.js +++ b/index.js @@ -171,10 +171,10 @@ export default (app) => { } // find regex [0-9]\+ in issue_body and get first result - let pr_number = issue_body.match(/[0-9]+/)[0]; + let pr_number = issue_body?.match(/[0-9]+/)?.[0] || ''; // Get answers to first question and find if they contain affirmative answer - let firstQuestionResponse = await getQuestionResponse(1, 2, issue_body); + let firstQuestionResponse = (await getQuestionResponse(1, 2, issue_body)) || []; let isCopilotUsed = firstQuestionResponse.some((response) => { return ( response.includes("Sim") || @@ -345,7 +345,8 @@ export default (app) => { let AnswerSelected = false; let Answers = new Array(); let Expression = end ? new RegExp(start + "\\. (.*" + end + "\\." + ")?", "s") : new RegExp(start + "\\. (.*" + ")?", "s"); - let QuestionOptions = issue_body.match(Expression)[0].match(/\[x\].*/g); + let question = issue_body?.match(Expression); + let QuestionOptions = question ? question[0].match(/\[x\].*/g) : null; if(QuestionOptions){ AnswerSelected = true; QuestionOptions.forEach((option) => { diff --git a/test/index.test.js b/test/index.test.js index 927b2bd..0538757 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -156,6 +156,17 @@ describe("My Probot app", () => { expect(mock.pendingMocks()).toStrictEqual([]); }); + test("handles edited survey bodies without PR numbers or question markers", async () => { + const payload = structuredClone(payload_issues_edited); + payload.issue.body = "This edited survey has no numbered question markers."; + + sql.Request.mockClear(); + await probot.receive({ name: "issues", payload }); + + const request = sql.Request.mock.results[0].value; + expect(request.input).toHaveBeenCalledWith("value5", ""); + }); + test("closes an issue if a comment is received", async () => { const mock = nock("https://api.github.com") // Test that we correctly return a test token From 19b8fe972d6a94e1e1e89926c32a85883e85a97f Mon Sep 17 00:00:00 2001 From: Mabel Geronimo <107436170+mageroni@users.noreply.github.com> Date: Thu, 12 Nov 2026 10:36:15 -0600 Subject: [PATCH 3/4] Update regex to extract PR number from issue body Do not include the words Pull Request in the match, just the symbol `#` Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index eb3d0b9..6d3484b 100644 --- a/index.js +++ b/index.js @@ -171,7 +171,7 @@ export default (app) => { } // find regex [0-9]\+ in issue_body and get first result - let pr_number = issue_body?.match(/[0-9]+/)?.[0] || ''; + let pr_number = issue_body?.match(/Pull Request\s+#?\s*([0-9]+)/i)?.[1] || ''; // Get answers to first question and find if they contain affirmative answer let firstQuestionResponse = (await getQuestionResponse(1, 2, issue_body)) || []; From fcd3da882e50167b891a79969f3b7a79d4302247 Mon Sep 17 00:00:00 2001 From: Mabel Geronimo <107436170+mageroni@users.noreply.github.com> Date: Thu, 12 Nov 2026 10:41:15 -0600 Subject: [PATCH 4/4] Fix regex to match pull request number format --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 6d3484b..d8ed44b 100644 --- a/index.js +++ b/index.js @@ -171,7 +171,7 @@ export default (app) => { } // find regex [0-9]\+ in issue_body and get first result - let pr_number = issue_body?.match(/Pull Request\s+#?\s*([0-9]+)/i)?.[1] || ''; + let pr_number = issue_body?.match(/#?\s*([0-9]+)/i)?.[1] || ''; // Get answers to first question and find if they contain affirmative answer let firstQuestionResponse = (await getQuestionResponse(1, 2, issue_body)) || []; @@ -384,4 +384,4 @@ class AppInsights { this.appIClient.trackException(exception); } } -} \ No newline at end of file +}