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({