From 80fbf61c51e77e787c17e41b585f44c63069311f Mon Sep 17 00:00:00 2001 From: Drew Bollinger <drew.bollinger@gsa.gov> Date: Wed, 13 Nov 2024 10:02:52 -0500 Subject: [PATCH] chore: don't fail the scheduled worker with missing sites --- api/workers/jobProcessors/buildTasksScheduler.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/api/workers/jobProcessors/buildTasksScheduler.js b/api/workers/jobProcessors/buildTasksScheduler.js index 37d7defe0..af821f1c7 100644 --- a/api/workers/jobProcessors/buildTasksScheduler.js +++ b/api/workers/jobProcessors/buildTasksScheduler.js @@ -28,9 +28,12 @@ async function buildTasksScheduler(job) { const tasksToQueue = await Promise.all( siteBuildTasks.map(async (siteBuildTask) => { // always use the branch config with site context - const { branch } = siteBuildTask.Site.SiteBranchConfigs.find( - (sbc) => sbc.context === 'site', - ); + const { branch } = + siteBuildTask.Site?.SiteBranchConfigs?.find((sbc) => sbc.context === 'site') || + {}; + + if (!branch) return Promise.resolve(null); + // find the latest build matching this branch // https://github.com/sequelize/sequelize/issues/7665 const builds = await Build.findAll({