@@ -27,6 +27,7 @@ import (
27
27
repository6 "github.com/devtron-labs/devtron/pkg/variables/repository"
28
28
util2 "github.com/devtron-labs/devtron/util"
29
29
"github.com/go-pg/pg"
30
+ "github.com/juju/errors"
30
31
"go.uber.org/zap"
31
32
"net/http"
32
33
)
@@ -190,18 +191,20 @@ func (impl *DeploymentConfigurationServiceImpl) getDeploymentHistoryConfig(ctx c
190
191
191
192
func (impl * DeploymentConfigurationServiceImpl ) getPipelineStrategyConfigHistory (ctx context.Context , configDataQueryParams * bean2.ConfigDataQueryParams ) (* bean2.DeploymentAndCmCsConfig , error ) {
192
193
pipelineStrategyJson := json.RawMessage {}
194
+ pipelineConfig := bean2 .NewDeploymentAndCmCsConfig ()
193
195
pipelineStrategyHistory , err := impl .pipelineStrategyHistoryRepository .GetHistoryByPipelineIdAndWfrId (ctx , configDataQueryParams .PipelineId , configDataQueryParams .WfrId )
194
- if err != nil {
196
+ if err != nil && ! util . IsErrNoRows ( err ) {
195
197
impl .logger .Errorw ("error in checking if history exists for pipelineId and wfrId" , "pipelineId" , configDataQueryParams .PipelineId , "wfrId" , configDataQueryParams .WfrId , "err" , err )
196
198
return nil , err
199
+ } else if util .IsErrNoRows (err ) {
200
+ return pipelineConfig , nil
197
201
}
198
202
err = pipelineStrategyJson .UnmarshalJSON ([]byte (pipelineStrategyHistory .Config ))
199
203
if err != nil {
200
204
impl .logger .Errorw ("getDeploymentTemplateForEnvLevel, error in unmarshalling string pipelineStrategyHistory data into json Raw message" , "pipelineStrategyHistoryConfig" , pipelineStrategyHistory .Config , "err" , err )
201
205
return nil , err
202
206
}
203
- pipelineConfig := bean2 .NewDeploymentAndCmCsConfig ().
204
- WithConfigData (pipelineStrategyJson ).
207
+ pipelineConfig .WithConfigData (pipelineStrategyJson ).
205
208
WithResourceType (bean .PipelineStrategy ).
206
209
WithPipelineStrategyMetadata (pipelineStrategyHistory .PipelineTriggerType , string (pipelineStrategyHistory .Strategy ))
207
210
return pipelineConfig , nil
@@ -640,9 +643,11 @@ func (impl *DeploymentConfigurationServiceImpl) getPublishedPipelineStrategyConf
640
643
return nil , err
641
644
}
642
645
pipelineStrategy , err := impl .deploymentConfigService .GetLatestPipelineStrategyConfig (pipeline )
643
- if err != nil {
646
+ if err != nil && ! errors . IsNotFound ( err ) {
644
647
impl .logger .Errorw ("error in GetLatestPipelineStrategyConfig" , "pipelineId" , pipeline .Id , "err" , err )
645
648
return nil , err
649
+ } else if errors .IsNotFound (err ) {
650
+ return pipelineConfig , nil
646
651
}
647
652
err = pipelineStrategyJson .UnmarshalJSON ([]byte (pipelineStrategy .CodeEditorValue .Value ))
648
653
if err != nil {
0 commit comments