diff --git a/chaoscenter/graphql/server/pkg/chaos_experiment/handler/handler.go b/chaoscenter/graphql/server/pkg/chaos_experiment/handler/handler.go index 419ae421dcb..bf54edd88f2 100644 --- a/chaoscenter/graphql/server/pkg/chaos_experiment/handler/handler.go +++ b/chaoscenter/graphql/server/pkg/chaos_experiment/handler/handler.go @@ -1516,7 +1516,7 @@ func (c *ChaosExperimentHandler) StopExperimentRuns(ctx context.Context, project if len(experimentRunsID) == 0 && experiment.CronSyntax == "" { return false, fmt.Errorf("no running or timeout experiments found") } - } else if experimentRunID != nil && *experimentRunID != "" { + } else if *experimentRunID != "" { experimentRunsID = []string{*experimentRunID} } diff --git a/chaoscenter/graphql/server/pkg/environment/handler/handler.go b/chaoscenter/graphql/server/pkg/environment/handler/handler.go index 8cd437ac419..f70d743b188 100644 --- a/chaoscenter/graphql/server/pkg/environment/handler/handler.go +++ b/chaoscenter/graphql/server/pkg/environment/handler/handler.go @@ -228,7 +228,7 @@ func (e *EnvironmentService) ListEnvironments(projectID string, request *model.L } // Filtering based on given parameters - if request.Filter != nil { + if request != nil && request.Filter != nil { // Filtering based on chaos_infra name if request.Filter.Name != nil && *request.Filter.Name != "" { matchInfraNameStage := bson.D{ @@ -280,7 +280,7 @@ func (e *EnvironmentService) ListEnvironments(projectID string, request *model.L var sortStage bson.D switch { - case request.Sort != nil && request.Sort.Field == model.EnvironmentSortingFieldTime: + case request != nil && request.Sort != nil && request.Sort.Field == model.EnvironmentSortingFieldTime: // Sorting based on created time if request.Sort.Ascending != nil && *request.Sort.Ascending { sortStage = bson.D{ @@ -295,7 +295,7 @@ func (e *EnvironmentService) ListEnvironments(projectID string, request *model.L }}, } } - case request.Sort != nil && request.Sort.Field == model.EnvironmentSortingFieldName: + case request != nil && request.Sort != nil && request.Sort.Field == model.EnvironmentSortingFieldName: // Sorting based on ExperimentName time if request.Sort.Ascending != nil && *request.Sort.Ascending { sortStage = bson.D{ @@ -324,7 +324,7 @@ func (e *EnvironmentService) ListEnvironments(projectID string, request *model.L sortStage, } - if request.Pagination != nil { + if request != nil && request.Pagination != nil { paginationSkipStage := bson.D{ {"$skip", request.Pagination.Page * request.Pagination.Limit}, } @@ -353,6 +353,7 @@ func (e *EnvironmentService) ListEnvironments(projectID string, request *model.L pipeline = append(pipeline, facetStage) cursor, err := e.EnvironmentOperator.GetAggregateEnvironments(pipeline) + if err != nil { return nil, err } @@ -368,6 +369,7 @@ func (e *EnvironmentService) ListEnvironments(projectID string, request *model.L Environments: envs, }, errors.New("error decoding environment cursor: " + err.Error()) } + if len(aggregatedEnvironments) == 0 { return &model.ListEnvironmentResponse{ TotalNoOfEnvironments: 0, diff --git a/chaoscenter/graphql/server/pkg/gitops/service.go b/chaoscenter/graphql/server/pkg/gitops/service.go index 2c19987af22..9ddf4091c50 100644 --- a/chaoscenter/graphql/server/pkg/gitops/service.go +++ b/chaoscenter/graphql/server/pkg/gitops/service.go @@ -621,12 +621,11 @@ func (g *gitOpsService) updateExperiment(ctx context.Context, data, wfID, file s } revID := "" - updateRevision := false input, wfType, err := g.chaosExperimentService.ProcessExperiment(ctx, &experimentData, config.ProjectID, revID) if err != nil { return err } - return g.chaosExperimentService.ProcessExperimentUpdate(input, "git-ops", wfType, revID, updateRevision, config.ProjectID, dataStore.Store) + return g.chaosExperimentService.ProcessExperimentUpdate(input, "git-ops", wfType, revID, false, config.ProjectID, dataStore.Store) } // deleteExperiment helps in deleting experiment from DB during the SyncDBToGit operation