7
7
appRepository "github.com/devtron-labs/devtron/internal/sql/repository/app"
8
8
"github.com/devtron-labs/devtron/internal/sql/repository/chartConfig"
9
9
"github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig"
10
+ "github.com/devtron-labs/devtron/internal/util"
10
11
bean3 "github.com/devtron-labs/devtron/pkg/bean"
11
12
chartService "github.com/devtron-labs/devtron/pkg/chart"
12
13
"github.com/devtron-labs/devtron/pkg/cluster/repository"
@@ -27,6 +28,7 @@ import (
27
28
util2 "github.com/devtron-labs/devtron/util"
28
29
"github.com/go-pg/pg"
29
30
"go.uber.org/zap"
31
+ "net/http"
30
32
)
31
33
32
34
type DeploymentConfigurationService interface {
@@ -175,9 +177,11 @@ func (impl *DeploymentConfigurationServiceImpl) getConfigDataForCdRollback(ctx c
175
177
func (impl * DeploymentConfigurationServiceImpl ) getDeploymentHistoryConfig (ctx context.Context , configDataQueryParams * bean2.ConfigDataQueryParams ) (* bean2.DeploymentAndCmCsConfig , error ) {
176
178
deploymentJson := json.RawMessage {}
177
179
deploymentHistory , err := impl .deploymentTemplateHistoryRepository .GetHistoryByPipelineIdAndWfrId (configDataQueryParams .PipelineId , configDataQueryParams .WfrId )
178
- if err != nil {
180
+ if err != nil && ! util . IsErrNoRows ( err ) {
179
181
impl .logger .Errorw ("error in getting deployment template history for pipelineId and wfrId" , "pipelineId" , configDataQueryParams .PipelineId , "wfrId" , configDataQueryParams .WfrId , "err" , err )
180
182
return nil , err
183
+ } else if util .IsErrNoRows (err ) {
184
+ return nil , util .GetApiError (http .StatusNotFound , bean2 .NoDeploymentDoneForSelectedImage , bean2 .NoDeploymentDoneForSelectedImage )
181
185
}
182
186
err = deploymentJson .UnmarshalJSON ([]byte (deploymentHistory .Template ))
183
187
if err != nil {
0 commit comments