diff --git a/pkg/appWorkflow/AppWorkflowService.go b/pkg/appWorkflow/AppWorkflowService.go index 66fcf67a39..7344294c36 100644 --- a/pkg/appWorkflow/AppWorkflowService.go +++ b/pkg/appWorkflow/AppWorkflowService.go @@ -437,6 +437,11 @@ func (impl AppWorkflowServiceImpl) FindAppWorkflowMappingForEnv(appIds []int) (m workflowMappings := make(map[int][]bean4.AppWorkflowMappingDto) workflows := make(map[int]*bean4.AppWorkflowDto) for _, w := range appWorkflowMappings { + if _, ok := pipelineMap[w.ComponentId]; !ok { + impl.Logger.Warnw("pipeline not found for componentId", "componentId", w.ComponentId, "appWorkflowId", w.AppWorkflowId) + // If the pipeline is not found, we skip adding this mapping as one possible reason would be pipeline have been deleted + continue + } if _, ok := workflows[w.AppWorkflowId]; !ok { workflows[w.AppWorkflowId] = &bean4.AppWorkflowDto{ Id: w.AppWorkflowId, diff --git a/pkg/pipeline/DeploymentPipelineConfigService.go b/pkg/pipeline/DeploymentPipelineConfigService.go index 00bfc63b60..86f57403aa 100644 --- a/pkg/pipeline/DeploymentPipelineConfigService.go +++ b/pkg/pipeline/DeploymentPipelineConfigService.go @@ -1821,6 +1821,11 @@ func (impl *CdPipelineConfigServiceImpl) GetCdPipelinesByEnvironment(request res } for _, dbPipeline := range authorizedPipelines { + if _, ok := pipelineWorkflowMapping[dbPipeline.Id]; !ok { + // can be due to concurrent deletion of pipeline, app workflow mapping + impl.logger.Warnw("pipeline workflow mapping not found for pipeline", "pipelineId", dbPipeline.Id) + continue + } var customTag *bean.CustomTagData var customTagStage repository5.PipelineStageType customTagPreCD := customTagMapResponse.GetCustomTagForEntityKey(pipelineConfigBean.EntityTypePreCD, strconv.Itoa(dbPipeline.Id))