From b1fc28e3ad84160a6f3a3d057318cc5ba90cfbe7 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 21 Jul 2026 12:06:52 +0000 Subject: [PATCH] Fix TypeError in child_process.spawnSync wrappers Update Node.js child_process.spawnSync wrappers in Tracker, GitHub, and Release Day services to defensively handle output objects. `spawnSync` may not always return a standard structure when the process cannot spawn (e.g., ENOENT for an unrecognized command). We now correctly verify types and test for `result.error` directly. Co-authored-by: breakingthebot <223392881+breakingthebot@users.noreply.github.com> --- src/services/githubSyncService.js | 2 +- src/services/releaseDayService.js | 2 +- src/services/trackerSyncService.js | 11 ++++++++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/services/githubSyncService.js b/src/services/githubSyncService.js index fd2b64a..a2cbd6e 100644 --- a/src/services/githubSyncService.js +++ b/src/services/githubSyncService.js @@ -44,7 +44,7 @@ function fetchPublicRepositories(owner) { }, ); - if (result.status !== 0) { + if (result.status !== 0 || result.error) { const stderr = typeof result.stderr === "string" ? result.stderr.trim() : ""; const stdout = typeof result.stdout === "string" ? result.stdout.trim() : ""; const processError = diff --git a/src/services/releaseDayService.js b/src/services/releaseDayService.js index 6ed5385..456bee8 100644 --- a/src/services/releaseDayService.js +++ b/src/services/releaseDayService.js @@ -27,7 +27,7 @@ function runCommand(command, args) { encoding: "utf8", }); - if (result.status !== 0) { + if (result.status !== 0 || result.error) { const stderr = typeof result.stderr === "string" ? result.stderr.trim() : ""; const stdout = typeof result.stdout === "string" ? result.stdout.trim() : ""; const processError = diff --git a/src/services/trackerSyncService.js b/src/services/trackerSyncService.js index 090e01a..8176db3 100644 --- a/src/services/trackerSyncService.js +++ b/src/services/trackerSyncService.js @@ -30,13 +30,18 @@ function runPowerShellScript(script) { encoding: "utf8", }); - if (result.status !== 0) { + if (result.status !== 0 || result.error) { + const stderr = typeof result.stderr === "string" ? result.stderr.trim() : ""; + const stdout = typeof result.stdout === "string" ? result.stdout.trim() : ""; + const processError = + result.error && result.error.message ? result.error.message : ""; + throw new Error( - result.stderr.trim() || result.stdout.trim() || "PowerShell script failed.", + processError || stderr || stdout || "PowerShell script failed.", ); } - return result.stdout.trim(); + return typeof result.stdout === "string" ? result.stdout.trim() : ""; } /**