From e7b293f075507332904cab19d3ef349edbf2dbdd Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 15 Aug 2025 17:55:59 +0000 Subject: [PATCH 1/3] Initial plan From 71b0bcf3bac04a098a45e9081a0124f3e1668749 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 15 Aug 2025 18:03:15 +0000 Subject: [PATCH 2/3] Fix action failure on PR close and convertValueToFieldType bug Co-authored-by: benbalter <282759+benbalter@users.noreply.github.com> --- __test__/main.test.ts | 18 ++++++++++++++++++ src/update-project.ts | 10 +++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/__test__/main.test.ts b/__test__/main.test.ts index cdb0672..99a59c1 100644 --- a/__test__/main.test.ts +++ b/__test__/main.test.ts @@ -235,6 +235,24 @@ describe("with Octokit setup", () => { expect(mock.done()).toBe(true); }); + test("fetchContentMetadata returns empty object if node is null", async () => { + const data = { + data: { + node: null, + }, + }; + mockGraphQL(data, "nullContentMetadata", "projectItems"); + + const result = await updateProject.fetchContentMetadata( + "PR_closed_node_id", + "test", + 1, + "github" + ); + expect(result).toEqual({}); + expect(mock.done()).toBe(true); + }); + test("fetchProjectMetadata fetches project metadata", async () => { const expected = { projectId: 1, diff --git a/src/update-project.ts b/src/update-project.ts index e10a7b1..3600899 100644 --- a/src/update-project.ts +++ b/src/update-project.ts @@ -76,6 +76,14 @@ export async function fetchContentMetadata( { contentId, fieldName } ); + // Handle case where node is null (e.g., when PR is closed without merging) + if (!result.node) { + setFailed( + `Content not found with ID ${contentId} - it may have been deleted or is not accessible` + ); + return {}; + } + const item = result.node.projectItems.nodes.find( (node: GraphQlQueryResponseData) => { return ( @@ -222,7 +230,7 @@ export function convertValueToFieldType( value: string, fieldType: string ): string | number { - if (fieldType === "NUMBER") { + if (fieldType === "number") { const numValue = parseFloat(value); if (isNaN(numValue)) { throw new Error(`Invalid number value: ${value}`); From fa194eefc4ac196ba979cb02296bb875b8639d1a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 15 Aug 2025 18:04:25 +0000 Subject: [PATCH 3/3] Package action with fixes for distribution Co-authored-by: benbalter <282759+benbalter@users.noreply.github.com> --- dist/index.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dist/index.js b/dist/index.js index bf3b290..0058404 100644 --- a/dist/index.js +++ b/dist/index.js @@ -9770,6 +9770,11 @@ function fetchContentMetadata(contentId, fieldName, projectNumber, owner) { } } `, { contentId, fieldName }); + // Handle case where node is null (e.g., when PR is closed without merging) + if (!result.node) { + (0, core_1.setFailed)(`Content not found with ID ${contentId} - it may have been deleted or is not accessible`); + return {}; + } const item = result.node.projectItems.nodes.find((node) => { return (node.project.number === projectNumber && node.project.owner.login === owner);