Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
fix: don't set internal error when error is nil (#4772)
Danny Xu49cdff24b343
diff --git a/backend/server/project.go b/backend/server/project.goindex e7512563ee..56825e1351 100644--- a/backend/server/project.go+++ b/backend/server/project.go@@ -283,11 +283,13 @@ func (s *Server) registerProjectRoutes(g *echo.Group) {// When the branch names doesn't contain wildcards, we should make sure the branch exists in the repo.if !strings.Contains(repositoryCreate.BranchFilter, "*") {- if notFound, err := isBranchNotFound(ctx, vcs, repositoryCreate.AccessToken, repositoryCreate.RefreshToken, repositoryCreate.ExternalID, repositoryCreate.BranchFilter); notFound {- return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Branch %q not found in repository %s.", repositoryCreate.BranchFilter, repositoryCreate.Name)).SetInternal(err)- } else if err != nil {+ notFound, err := isBranchNotFound(ctx, vcs, repositoryCreate.AccessToken, repositoryCreate.RefreshToken, repositoryCreate.ExternalID, repositoryCreate.BranchFilter)+ if err != nil {return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to get branch %q", repositoryCreate.BranchFilter)).SetInternal(err)}+ if notFound {+ return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Branch %q not found in repository %s.", repositoryCreate.BranchFilter, repositoryCreate.Name))+ }}// For a particular VCS repo, all Bytebase projects share the same webhook.@@ -504,11 +506,13 @@ func (s *Server) registerProjectRoutes(g *echo.Group) {// When the branch names doesn't contain wildcards, we should make sure the branch exists in the repo.if !strings.Contains(newBranchFilter, "*") {- if notFound, err := isBranchNotFound(ctx, vcs, repo.AccessToken, repo.RefreshToken, repo.ExternalID, newBranchFilter); notFound {- return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Branch %q not found in repository %s.", newBranchFilter, repo.Name)).SetInternal(err)- } else if err != nil {+ notFound, err := isBranchNotFound(ctx, vcs, repo.AccessToken, repo.RefreshToken, repo.ExternalID, newBranchFilter)+ if err != nil {return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to get branch %q", newBranchFilter)).SetInternal(err)}+ if notFound {+ return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Branch %q not found in repository %s.", newBranchFilter, repo.Name))+ }}// We need to check the FilePathTemplate in create repository request.