Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: handle zero change (#11575)

Danny Xu07de2592b9ce
diff --git a/backend/api/gitops/common.go b/backend/api/gitops/common.go
index e16074b067..c0bff5939f 100644
--- a/backend/api/gitops/common.go
+++ b/backend/api/gitops/common.go
@@ -32,13 +32,13 @@ type fileChange struct {
content string
}
-func getChangesByFileList(files []*vcs.PullRequestFile, branch string) []*fileChange {
+func getChangesByFileList(files []*vcs.PullRequestFile, rootDir string) []*fileChange {
changes := []*fileChange{}
for _, v := range files {
if v.IsDeleted {
continue
}
- if filepath.Dir(v.Path) != branch {
+ if filepath.Dir(v.Path) != rootDir {
continue
}
change, err := getFileChange(v.Path)
diff --git a/backend/api/gitops/webhook.go b/backend/api/gitops/webhook.go
index 2f4534fe89..467fec3a3e 100644
--- a/backend/api/gitops/webhook.go
+++ b/backend/api/gitops/webhook.go
@@ -145,6 +145,9 @@ func (s *Service) RegisterWebhookRoutes(g *echo.Group) {
default:
return nil
}
+ if len(prInfo.changes) == 0 {
+ return c.String(http.StatusOK, fmt.Sprintf("no relevant file change directly under the base directory %q for pull request %q", vcsConnector.Payload.BaseDirectory, prInfo.url))
+ }
issue, err := s.createIssueFromPRInfo(ctx, project, vcsProvider, vcsConnector, prInfo)
if err != nil {
return c.String(http.StatusOK, fmt.Sprintf("failed to create issue from pull request %s, error %v", prInfo.url, err))
diff --git a/backend/api/v1/rollout_service.go b/backend/api/v1/rollout_service.go
index 9f46af3882..50213facb8 100644
--- a/backend/api/v1/rollout_service.go
+++ b/backend/api/v1/rollout_service.go
@@ -1399,9 +1399,15 @@ func diffSpecs(oldSteps []*v1pb.Plan_Step, newSteps []*v1pb.Plan_Step) ([]*v1pb.
}
func validateSteps(steps []*v1pb.Plan_Step) error {
+ if len(steps) == 0 {
+ return errors.Errorf("the plan has zero step")
+ }
var databaseTarget, databaseGroupTarget, deploymentConfigTarget int
seenID := map[string]bool{}
for _, step := range steps {
+ if len(step.Specs) == 0 {
+ return errors.Errorf("the plan step has zero spec")
+ }
seenIDInStep := map[string]bool{}
for _, spec := range step.Specs {
id := spec.GetId()