Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
Use int instead of string for the error code
天舟d0b8c4d2a536
diff --git a/common/error.go b/common/error.goindex d6420951c5..30c8d15986 100644--- a/common/error.go+++ b/common/error.go@@ -5,18 +5,18 @@ import ("fmt")+type Code int+// Application error codes.-//-// NOTE: These are meant to be generic and they map well to HTTP error codes.-// Different applications can have very different error code requirements so-// these should be expanded as needed (or introduce subcodes).const (- ECONFLICT = "conflict"- EINTERNAL = "internal"- EINVALID = "invalid"- ENOTFOUND = "not_found"- ENOTIMPLEMENTED = "not_implemented"- EUNAUTHORIZED = "unauthorized"+ // 0 ~ 99 general error+ Ok Code = 0+ Internal Code = 1+ NotAuthorized Code = 2+ Invalid Code = 3+ NotFound Code = 4+ Conflict Code = 5+ NotImplemented Code = 6)// Error represents an application-specific error. Application errors can be@@ -28,7 +28,7 @@ const (// reported to the operator of the application (not the end user).type Error struct {// Machine-readable error code.- Code string+ Code Code// Human-readable error message.Message string@@ -36,19 +36,19 @@ type Error struct {// Error implements the error interface. Not used by the application otherwise.func (e *Error) Error() string {- return fmt.Sprintf("bytebase error: code=%s message=%s", e.Code, e.Message)+ return fmt.Sprintf("bytebase error: code=%d message=%s", e.Code, e.Message)}// ErrorCode unwraps an application error and returns its code.// Non-application errors always return EINTERNAL.-func ErrorCode(err error) string {+func ErrorCode(err error) Code {var e *Errorif err == nil {- return ""+ return Ok} else if errors.As(err, &e) {return e.Code}- return EINTERNAL+ return Internal}// ErrorMessage unwraps an application error and returns its message.@@ -64,7 +64,7 @@ func ErrorMessage(err error) string {}// Errorf is a helper function to return an Error with a given code and formatted message.-func Errorf(code string, format string, args ...interface{}) *Error {+func Errorf(code Code, format string, args ...interface{}) *Error {return &Error{Code: code,Message: fmt.Sprintf(format, args...),diff --git a/server/acl.go b/server/acl.goindex c1a9006606..af402fe72d 100644--- a/server/acl.go+++ b/server/acl.go@@ -43,7 +43,7 @@ func ACLMiddleware(l *zap.Logger, s *Server, ce *casbin.Enforcer, next echo.Hand}member, err := s.MemberService.FindMember(context.Background(), memberFind)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return echo.NewHTTPError(http.StatusUnauthorized, fmt.Sprintf("User ID is not a member: %d", principalId))}return echo.NewHTTPError(http.StatusInternalServerError, "Failed to process authorize request.").SetInternal(err)@@ -71,7 +71,7 @@ func ACLMiddleware(l *zap.Logger, s *Server, ce *casbin.Enforcer, next echo.Hand}activity, err := s.ActivityService.FindActivity(context.Background(), activityFind)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return echo.NewHTTPError(http.StatusUnauthorized, fmt.Sprintf("Activity ID not found: %d", activityId))}return echo.NewHTTPError(http.StatusInternalServerError, "Failed to process authorize request.").SetInternal(err)@@ -92,7 +92,7 @@ func ACLMiddleware(l *zap.Logger, s *Server, ce *casbin.Enforcer, next echo.Hand}bookmark, err := s.BookmarkService.FindBookmark(context.Background(), bookmarkFind)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return echo.NewHTTPError(http.StatusUnauthorized, fmt.Sprintf("Bookmark ID not found: %d", bookmarkId))}return echo.NewHTTPError(http.StatusInternalServerError, "Failed to process authorize request.").SetInternal(err)@@ -113,7 +113,7 @@ func ACLMiddleware(l *zap.Logger, s *Server, ce *casbin.Enforcer, next echo.Hand}inbox, err := s.InboxService.FindInbox(context.Background(), inboxFind)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return echo.NewHTTPError(http.StatusUnauthorized, fmt.Sprintf("Inbox ID not found: %d", inboxId))}return echo.NewHTTPError(http.StatusInternalServerError, "Failed to process authorize request.").SetInternal(err)diff --git a/server/activity.go b/server/activity.goindex 8010c119eb..7b8ccc50e9 100644--- a/server/activity.go+++ b/server/activity.go@@ -29,7 +29,7 @@ func (s *Server) registerActivityRoutes(g *echo.Group) {}issue, err := s.IssueService.FindIssue(context.Background(), issueFind)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Unable to find issue ID for creating the comment: %d", activityCreate.ContainerId))}return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to fetch issue ID when creating the comment: %d", activityCreate.ContainerId)).SetInternal(err)@@ -113,7 +113,7 @@ func (s *Server) registerActivityRoutes(g *echo.Group) {activity, err := s.ActivityService.PatchActivity(context.Background(), activityPatch)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Activity ID not found: %d", id))}return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to patch activity ID: %v", id)).SetInternal(err)@@ -142,7 +142,7 @@ func (s *Server) registerActivityRoutes(g *echo.Group) {}err = s.ActivityService.DeleteActivity(context.Background(), activityDelete)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Activity ID not found: %d", id))}return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to delete activity ID: %v", id)).SetInternal(err)diff --git a/server/auth.go b/server/auth.goindex 512e6a95fc..c5ab0a35c3 100644--- a/server/auth.go+++ b/server/auth.go@@ -25,7 +25,7 @@ func (s *Server) registerAuthRoutes(g *echo.Group) {}user, err := s.PrincipalService.FindPrincipal(context.Background(), principalFind)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return echo.NewHTTPError(http.StatusUnauthorized, fmt.Sprintf("User not found: %s", login.Email))}return echo.NewHTTPError(http.StatusInternalServerError, "Failed to authenticate user").SetInternal(err)@@ -36,7 +36,7 @@ func (s *Server) registerAuthRoutes(g *echo.Group) {}member, err := s.MemberService.FindMember(context.Background(), memberFind)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return echo.NewHTTPError(http.StatusUnauthorized, fmt.Sprintf("Member not found: %s", login.Email))}return echo.NewHTTPError(http.StatusInternalServerError, "Failed to authenticate user").SetInternal(err)@@ -94,7 +94,7 @@ func (s *Server) registerAuthRoutes(g *echo.Group) {user, err := s.PrincipalService.CreatePrincipal(context.Background(), principalCreate)if err != nil {- if common.ErrorCode(err) == common.ECONFLICT {+ if common.ErrorCode(err) == common.Conflict {return echo.NewHTTPError(http.StatusConflict, fmt.Sprintf("Email already exists: %s", signup.Email))}return echo.NewHTTPError(http.StatusInternalServerError, "Failed to signup").SetInternal(err)@@ -123,7 +123,7 @@ func (s *Server) registerAuthRoutes(g *echo.Group) {member, err := s.MemberService.CreateMember(context.Background(), memberCreate)if err != nil {- if common.ErrorCode(err) == common.ECONFLICT {+ if common.ErrorCode(err) == common.Conflict {return echo.NewHTTPError(http.StatusConflict, fmt.Sprintf("Member already exists: %s", signup.Email))}return echo.NewHTTPError(http.StatusInternalServerError, "Failed to signup").SetInternal(err)diff --git a/server/backup_runner.go b/server/backup_runner.goindex 15132519f0..5bf21cb064 100644--- a/server/backup_runner.go+++ b/server/backup_runner.go@@ -110,7 +110,7 @@ func (s *BackupRunner) scheduleBackupTask(database *api.Database, backupName str}backup, err := s.server.BackupService.CreateBackup(context.Background(), backupCreate)if err != nil {- if common.ErrorCode(err) == common.ECONFLICT {+ if common.ErrorCode(err) == common.Conflict {// Automatic backup already exists.return nil}diff --git a/server/bookmark.go b/server/bookmark.goindex 272dbb2d9b..6d71e861e2 100644--- a/server/bookmark.go+++ b/server/bookmark.go@@ -23,7 +23,7 @@ func (s *Server) registerBookmarkRoutes(g *echo.Group) {bookmark, err := s.BookmarkService.CreateBookmark(context.Background(), bookmarkCreate)if err != nil {- if common.ErrorCode(err) == common.ECONFLICT {+ if common.ErrorCode(err) == common.Conflict {return echo.NewHTTPError(http.StatusConflict, fmt.Sprintf("Bookmark already exists: %s", bookmarkCreate.Link))}return echo.NewHTTPError(http.StatusInternalServerError, "Failed to create bookmark").SetInternal(err)@@ -75,7 +75,7 @@ func (s *Server) registerBookmarkRoutes(g *echo.Group) {}err = s.BookmarkService.DeleteBookmark(context.Background(), bookmarkDelete)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Bookmark ID not found: %d", id))}return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to delete bookmark ID: %v", id)).SetInternal(err)diff --git a/server/database.go b/server/database.goindex b84214e6cf..e9561d0071 100644--- a/server/database.go+++ b/server/database.go@@ -35,7 +35,7 @@ func (s *Server) registerDatabaseRoutes(g *echo.Group) {database, err := s.DatabaseService.CreateDatabase(context.Background(), databaseCreate)if err != nil {- if common.ErrorCode(err) == common.ECONFLICT {+ if common.ErrorCode(err) == common.Conflict {return echo.NewHTTPError(http.StatusConflict, fmt.Sprintf("Database name already exists: %s", databaseCreate.Name))}return echo.NewHTTPError(http.StatusInternalServerError, "Failed to create database").SetInternal(err)@@ -115,7 +115,7 @@ func (s *Server) registerDatabaseRoutes(g *echo.Group) {}database, err := s.ComposeDatabaseByFind(context.Background(), databaseFind)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Database ID not found: %d", id))}return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to fetch database ID: %v", id)).SetInternal(err)@@ -150,7 +150,7 @@ func (s *Server) registerDatabaseRoutes(g *echo.Group) {ID: &databasePatch.ID,})if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Database ID not found: %d", id))}return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to patch database ID: %v", id)).SetInternal(err)@@ -159,7 +159,7 @@ func (s *Server) registerDatabaseRoutes(g *echo.Group) {database, err := s.DatabaseService.PatchDatabase(context.Background(), databasePatch)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Database ID not found: %d", id))}return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to patch database ID: %v", id)).SetInternal(err)@@ -240,7 +240,7 @@ func (s *Server) registerDatabaseRoutes(g *echo.Group) {}database, err := s.ComposeDatabaseByFind(context.Background(), databaseFind)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Database ID not found: %d", id))}return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to fetch database ID: %v", id)).SetInternal(err)@@ -293,7 +293,7 @@ func (s *Server) registerDatabaseRoutes(g *echo.Group) {}database, err := s.ComposeDatabaseByFind(context.Background(), databaseFind)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Database ID not found: %d", id))}return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to fetch database ID: %v", id)).SetInternal(err)@@ -353,7 +353,7 @@ func (s *Server) registerDatabaseRoutes(g *echo.Group) {}database, err := s.ComposeDatabaseByFind(context.Background(), databaseFind)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Database ID not found: %d", id))}return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to fetch database ID: %v", id)).SetInternal(err)@@ -372,7 +372,7 @@ func (s *Server) registerDatabaseRoutes(g *echo.Group) {backup, err := s.BackupService.CreateBackup(context.Background(), backupCreate)if err != nil {- if common.ErrorCode(err) == common.ECONFLICT {+ if common.ErrorCode(err) == common.Conflict {return echo.NewHTTPError(http.StatusConflict, fmt.Sprintf("Backup name already exists: %s", backupCreate.Name))}return echo.NewHTTPError(http.StatusInternalServerError, "Failed to create backup").SetInternal(err)@@ -440,7 +440,7 @@ func (s *Server) registerDatabaseRoutes(g *echo.Group) {}_, err = s.ComposeDatabaseByFind(context.Background(), databaseFind)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Database ID not found: %d", id))}return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to fetch database ID: %v", id)).SetInternal(err)@@ -484,7 +484,7 @@ func (s *Server) registerDatabaseRoutes(g *echo.Group) {}db, err := s.ComposeDatabaseByFind(context.Background(), databaseFind)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Database ID not found: %d", id))}return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to fetch database ID: %v", id)).SetInternal(err)@@ -514,7 +514,7 @@ func (s *Server) registerDatabaseRoutes(g *echo.Group) {}_, err = s.ComposeDatabaseByFind(context.Background(), databaseFind)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Database ID not found: %d", id))}return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to fetch database ID: %v", id)).SetInternal(err)@@ -525,7 +525,7 @@ func (s *Server) registerDatabaseRoutes(g *echo.Group) {}backupSetting, err := s.BackupService.FindBackupSetting(context.Background(), backupSettingFind)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {// Returns the backup setting with UNKNOWN_ID to indicate the database has no backupbackupSetting = &api.BackupSetting{ID: api.UNKNOWN_ID,diff --git a/server/environment.go b/server/environment.goindex 9f659990da..35950090d2 100644--- a/server/environment.go+++ b/server/environment.go@@ -24,7 +24,7 @@ func (s *Server) registerEnvironmentRoutes(g *echo.Group) {environment, err := s.EnvironmentService.CreateEnvironment(context.Background(), environmentCreate)if err != nil {- if common.ErrorCode(err) == common.ECONFLICT {+ if common.ErrorCode(err) == common.Conflict {return echo.NewHTTPError(http.StatusConflict, fmt.Sprintf("Environment name already exists: %s", environmentCreate.Name))}return echo.NewHTTPError(http.StatusInternalServerError, "Failed to create environment").SetInternal(err)@@ -81,7 +81,7 @@ func (s *Server) registerEnvironmentRoutes(g *echo.Group) {environment, err := s.EnvironmentService.PatchEnvironment(context.Background(), environmentPatch)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Environment ID not found: %d", id))}return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to patch environment ID: %v", id)).SetInternal(err)@@ -109,7 +109,7 @@ func (s *Server) registerEnvironmentRoutes(g *echo.Group) {environmentPatch.UpdaterId = c.Get(GetPrincipalIdContextKey()).(int)_, err = s.EnvironmentService.PatchEnvironment(context.Background(), environmentPatch)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Environment ID not found: %d", environmentPatch.ID))}return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to patch environment ID: %v", environmentPatch.ID)).SetInternal(err)diff --git a/server/inbox.go b/server/inbox.goindex cc03afe2d0..dcf60e6886 100644--- a/server/inbox.go+++ b/server/inbox.go@@ -82,7 +82,7 @@ func (s *Server) registerInboxRoutes(g *echo.Group) {inbox, err := s.InboxService.PatchInbox(context.Background(), inboxPatch)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Inbox ID not found: %d", id))}return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to patch inbox ID: %v", id)).SetInternal(err)diff --git a/server/instance.go b/server/instance.goindex 45b878c3f3..2352b4ceef 100644--- a/server/instance.go+++ b/server/instance.go@@ -25,7 +25,7 @@ func (s *Server) registerInstanceRoutes(g *echo.Group) {instance, err := s.InstanceService.CreateInstance(context.Background(), instanceCreate)if err != nil {- if common.ErrorCode(err) == common.ECONFLICT {+ if common.ErrorCode(err) == common.Conflict {return echo.NewHTTPError(http.StatusConflict, fmt.Sprintf("Instance name already exists: %s", instanceCreate.Name))}return echo.NewHTTPError(http.StatusInternalServerError, "Failed to create instance").SetInternal(err)@@ -86,7 +86,7 @@ func (s *Server) registerInstanceRoutes(g *echo.Group) {instance, err := s.ComposeInstanceById(context.Background(), id)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Instance ID not found: %d", id))}return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to fetch instance ID: %v", id)).SetInternal(err)@@ -117,7 +117,7 @@ func (s *Server) registerInstanceRoutes(g *echo.Group) {if instancePatch.RowStatus != nil || instancePatch.Name != nil || instancePatch.ExternalLink != nil || instancePatch.Host != nil || instancePatch.Port != nil {instance, err = s.InstanceService.PatchInstance(context.Background(), instancePatch)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Instance ID not found: %d", id))}return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to patch instance ID: %v", id)).SetInternal(err)@@ -130,7 +130,7 @@ func (s *Server) registerInstanceRoutes(g *echo.Group) {}instance, err = s.InstanceService.FindInstance(context.Background(), instanceFind)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Instance ID not found: %d", id))}return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to fetch instance ID: %v", id)).SetInternal(err)@@ -198,7 +198,7 @@ func (s *Server) registerInstanceRoutes(g *echo.Group) {instance, err := s.ComposeInstanceById(context.Background(), id)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Instance ID not found: %d", id))}return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to fetch instance ID: %v", id)).SetInternal(err)@@ -243,7 +243,7 @@ func (s *Server) registerInstanceRoutes(g *echo.Group) {instance, err := s.ComposeInstanceById(context.Background(), id)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Instance ID not found: %d", id))}return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to fetch instance ID: %v", id)).SetInternal(err)@@ -287,7 +287,7 @@ func (s *Server) registerInstanceRoutes(g *echo.Group) {instance, err := s.ComposeInstanceById(context.Background(), id)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Instance ID not found: %d", id))}return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to fetch instance ID: %v", id)).SetInternal(err)@@ -340,7 +340,7 @@ func (s *Server) registerInstanceRoutes(g *echo.Group) {instance, err := s.ComposeInstanceById(context.Background(), id)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Instance ID not found: %d", id))}return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to fetch instance ID: %v", id)).SetInternal(err)@@ -471,5 +471,5 @@ func (s *Server) FindInstanceAdminPasswordById(ctx context.Context, instanceId ireturn dataSource.Password, nil}}- return "", &common.Error{Code: common.ENOTFOUND, Message: fmt.Sprintf("missing admin password for instance: %d", instanceId)}+ return "", &common.Error{Code: common.NotFound, Message: fmt.Sprintf("missing admin password for instance: %d", instanceId)}}diff --git a/server/issue.go b/server/issue.goindex bfac5b5d73..ad418eeded 100644--- a/server/issue.go+++ b/server/issue.go@@ -140,7 +140,7 @@ func (s *Server) registerIssueRoutes(g *echo.Group) {issue, err := s.ComposeIssueById(context.Background(), id)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Issue ID not found: %d", id))}return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to fetch issue ID: %v", id)).SetInternal(err)@@ -172,7 +172,7 @@ func (s *Server) registerIssueRoutes(g *echo.Group) {}issue, err := s.IssueService.FindIssue(context.Background(), issueFind)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Unable to find issue ID to update: %d", id))}return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to fetch issue ID when updating issue: %v", id)).SetInternal(err)@@ -264,7 +264,7 @@ func (s *Server) registerIssueRoutes(g *echo.Group) {issue, err := s.ComposeIssueById(context.Background(), id)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Issue ID not found: %d", id))}return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to fetch issue ID: %v", id)).SetInternal(err)@@ -272,9 +272,9 @@ func (s *Server) registerIssueRoutes(g *echo.Group) {updatedIssue, err := s.ChangeIssueStatus(context.Background(), issue, issueStatusPatch.Status, issueStatusPatch.UpdaterId, issueStatusPatch.Comment)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return echo.NewHTTPError(http.StatusNotFound).SetInternal(err)- } else if common.ErrorCode(err) == common.ECONFLICT {+ } else if common.ErrorCode(err) == common.Conflict {return echo.NewHTTPError(http.StatusConflict).SetInternal(err)}return echo.NewHTTPError(http.StatusInternalServerError).SetInternal(err)@@ -499,7 +499,7 @@ func (s *Server) ChangeIssueStatus(ctx context.Context, issue *api.Issue, newStafor _, stage := range issue.Pipeline.StageList {for _, task := range stage.TaskList {if task.Status != api.TaskDone {- return nil, &common.Error{Code: common.ECONFLICT, Message: fmt.Sprintf("failed to resolve issue: %v, task %v has not finished", issue.Name, task.Name)}+ return nil, &common.Error{Code: common.Conflict, Message: fmt.Sprintf("failed to resolve issue: %v, task %v has not finished", issue.Name, task.Name)}}}}@@ -536,7 +536,7 @@ func (s *Server) ChangeIssueStatus(ctx context.Context, issue *api.Issue, newSta}updatedIssue, err := s.IssueService.PatchIssue(context.Background(), issuePatch)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return nil, fmt.Errorf("failed to update issue status: %v, error: %w", issue.Name, err)}return nil, fmt.Errorf("failed update issue status: %v, error: %w", issue.Name, err)diff --git a/server/issue_subscriber.go b/server/issue_subscriber.goindex 1bb485056c..2ec415f957 100644--- a/server/issue_subscriber.go+++ b/server/issue_subscriber.go@@ -28,7 +28,7 @@ func (s *Server) registerIssueSubscriberRoutes(g *echo.Group) {issueSubscriber, err := s.IssueSubscriberService.CreateIssueSubscriber(context.Background(), issueSubscriberCreate)if err != nil {- if common.ErrorCode(err) == common.ECONFLICT {+ if common.ErrorCode(err) == common.Conflict {return echo.NewHTTPError(http.StatusConflict, fmt.Sprintf("Subscriber %d already exists in issue %d", issueSubscriberCreate.SubscriberId, issueSubscriberCreate.IssueId))}return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to add subscriber %d to issue %d", issueSubscriberCreate.SubscriberId, issueSubscriberCreate.IssueId)).SetInternal(err)@@ -89,7 +89,7 @@ func (s *Server) registerIssueSubscriberRoutes(g *echo.Group) {}err = s.IssueSubscriberService.DeleteIssueSubscriber(context.Background(), issueSubscriberDelete)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Subscriber %d not found in issue %d", subscriberId, issueId))}return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to delete subscriber %d from issue %d", subscriberId, issueId)).SetInternal(err)diff --git a/server/jwt.go b/server/jwt.goindex e359876734..57e45aedb7 100644--- a/server/jwt.go+++ b/server/jwt.go@@ -220,7 +220,7 @@ func JWTMiddleware(l *zap.Logger, p api.PrincipalService, next echo.HandlerFunc,}user, err := p.FindPrincipal(context.Background(), principalFind)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return echo.NewHTTPError(http.StatusUnauthorized, fmt.Sprintf("Failed to find user ID: %d", principalId))}return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Server error to find user ID: %d", principalId)).SetInternal(err)diff --git a/server/member.go b/server/member.goindex 7849f9c59b..2a93285f84 100644--- a/server/member.go+++ b/server/member.go@@ -24,7 +24,7 @@ func (s *Server) registerMemberRoutes(g *echo.Group) {member, err := s.MemberService.CreateMember(context.Background(), memberCreate)if err != nil {- if common.ErrorCode(err) == common.ECONFLICT {+ if common.ErrorCode(err) == common.Conflict {return echo.NewHTTPError(http.StatusConflict, fmt.Sprintf("Member for user ID already exists: %d", memberCreate.PrincipalId))}return echo.NewHTTPError(http.StatusInternalServerError, "Failed to create member").SetInternal(err)@@ -37,7 +37,7 @@ func (s *Server) registerMemberRoutes(g *echo.Group) {}user, err := s.PrincipalService.FindPrincipal(context.Background(), principalFind)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return echo.NewHTTPError(http.StatusUnauthorized, fmt.Sprintf("Failed to find user ID: %d", member.PrincipalId))}return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Server error to find user ID: %d", member.PrincipalId)).SetInternal(err)@@ -108,7 +108,7 @@ func (s *Server) registerMemberRoutes(g *echo.Group) {}member, err := s.MemberService.FindMember(context.Background(), memberFind)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return echo.NewHTTPError(http.StatusUnauthorized, fmt.Sprintf("Failed to find member ID: %d", id))}return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Server error to find member ID: %d", id)).SetInternal(err)@@ -124,7 +124,7 @@ func (s *Server) registerMemberRoutes(g *echo.Group) {updatedMember, err := s.MemberService.PatchMember(context.Background(), memberPatch)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Member ID not found: %d", id))}return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to patch member ID: %v", id)).SetInternal(err)@@ -137,7 +137,7 @@ func (s *Server) registerMemberRoutes(g *echo.Group) {}user, err := s.PrincipalService.FindPrincipal(context.Background(), principalFind)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return echo.NewHTTPError(http.StatusUnauthorized, fmt.Sprintf("Failed to find user ID: %d", updatedMember.PrincipalId))}return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Server error to find user ID: %d", updatedMember.PrincipalId)).SetInternal(err)diff --git a/server/principal.go b/server/principal.goindex b7a8faa79c..7669e34878 100644--- a/server/principal.go+++ b/server/principal.go@@ -31,7 +31,7 @@ func (s *Server) registerPrincipalRoutes(g *echo.Group) {principal, err := s.PrincipalService.CreatePrincipal(context.Background(), principalCreate)if err != nil {- if common.ErrorCode(err) == common.ECONFLICT {+ if common.ErrorCode(err) == common.Conflict {return echo.NewHTTPError(http.StatusConflict, "User already exists")}return echo.NewHTTPError(http.StatusInternalServerError, "Failed to create principal").SetInternal(err)@@ -57,7 +57,7 @@ func (s *Server) registerPrincipalRoutes(g *echo.Group) {if err := s.ComposePrincipalRole(context.Background(), principal); err != nil {// Normally this should not happen since we create the member together with the principal// and we don't allow deleting the member. Just in case.- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {s.l.Error("Principal has not been assigned a role. Skip",zap.Int("id", principal.ID),zap.String("name", principal.Name),@@ -84,7 +84,7 @@ func (s *Server) registerPrincipalRoutes(g *echo.Group) {principal, err := s.ComposePrincipalById(context.Background(), id)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("User ID not found: %d", id))}return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to fetch principal ID: %v", id)).SetInternal(err)@@ -121,7 +121,7 @@ func (s *Server) registerPrincipalRoutes(g *echo.Group) {principal, err := s.PrincipalService.PatchPrincipal(context.Background(), principalPatch)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("User ID not found: %d", id))}return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to patch principal ID: %v", id)).SetInternal(err)diff --git a/server/project.go b/server/project.goindex 1d50c969fb..1962b124f2 100644--- a/server/project.go+++ b/server/project.go@@ -27,7 +27,7 @@ func (s *Server) registerProjectRoutes(g *echo.Group) {projectCreate.CreatorId = c.Get(GetPrincipalIdContextKey()).(int)project, err := s.ProjectService.CreateProject(context.Background(), projectCreate)if err != nil {- if common.ErrorCode(err) == common.ECONFLICT {+ if common.ErrorCode(err) == common.Conflict {return echo.NewHTTPError(http.StatusConflict, fmt.Sprintf("Project name already exists: %s", projectCreate.Name))}return echo.NewHTTPError(http.StatusInternalServerError, "Failed to create project").SetInternal(err)@@ -95,7 +95,7 @@ func (s *Server) registerProjectRoutes(g *echo.Group) {project, err := s.ComposeProjectlById(context.Background(), id)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Project ID not found: %d", id))}return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to fetch project ID: %v", id)).SetInternal(err)@@ -124,7 +124,7 @@ func (s *Server) registerProjectRoutes(g *echo.Group) {project, err := s.ProjectService.PatchProject(context.Background(), projectPatch)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Project ID not found: %d", id))}return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to patch project ID: %v", id)).SetInternal(err)@@ -161,7 +161,7 @@ func (s *Server) registerProjectRoutes(g *echo.Group) {}vcs, err := s.VCSService.FindVCS(context.Background(), vcsFind)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("VCS ID not found: %d", repositoryCreate.VCSId))}return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to find VCS for creating repository: %d", repositoryCreate.VCSId)).SetInternal(err)@@ -210,7 +210,7 @@ func (s *Server) registerProjectRoutes(g *echo.Group) {repositoryCreate.BaseDirectory = strings.Trim(repositoryCreate.BaseDirectory, "/")repository, err := s.RepositoryService.CreateRepository(context.Background(), repositoryCreate)if err != nil {- if common.ErrorCode(err) == common.ECONFLICT {+ if common.ErrorCode(err) == common.Conflict {return echo.NewHTTPError(http.StatusConflict, fmt.Sprintf("Project %d has already linked repository", repositoryCreate.ProjectId))}return echo.NewHTTPError(http.StatusInternalServerError, "Failed to link project repository").SetInternal(err)diff --git a/server/project_member.go b/server/project_member.goindex 8fe6de0b73..c5a5106a30 100644--- a/server/project_member.go+++ b/server/project_member.go@@ -30,7 +30,7 @@ func (s *Server) registerProjectMemberRoutes(g *echo.Group) {projectMember, err := s.ProjectMemberService.CreateProjectMember(context.Background(), projectMemberCreate)if err != nil {- if common.ErrorCode(err) == common.ECONFLICT {+ if common.ErrorCode(err) == common.Conflict {return echo.NewHTTPError(http.StatusConflict, "User is already a project member")}return echo.NewHTTPError(http.StatusInternalServerError, "Failed to create project member").SetInternal(err)@@ -80,7 +80,7 @@ func (s *Server) registerProjectMemberRoutes(g *echo.Group) {existingProjectMember, err := s.ProjectMemberService.FindProjectMember(context.Background(), &api.ProjectMemberFind{ID: &id})if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Project member ID not found: %d", id))}return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to delete project member ID: %v", id)).SetInternal(err)@@ -96,7 +96,7 @@ func (s *Server) registerProjectMemberRoutes(g *echo.Group) {projectMember, err := s.ProjectMemberService.PatchProjectMember(context.Background(), projectMemberPatch)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Project member ID not found: %d", id))}return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to change project membership ID: %v", id)).SetInternal(err)@@ -147,7 +147,7 @@ func (s *Server) registerProjectMemberRoutes(g *echo.Group) {projectMember, err := s.ProjectMemberService.FindProjectMember(context.Background(), &api.ProjectMemberFind{ID: &id})if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Project member ID not found: %d", id))}return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to delete project member ID: %v", id)).SetInternal(err)@@ -159,7 +159,7 @@ func (s *Server) registerProjectMemberRoutes(g *echo.Group) {}err = s.ProjectMemberService.DeleteProjectMember(context.Background(), projectMemberDelete)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Project member ID not found: %d", id))}return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to delete project member ID: %v", id)).SetInternal(err)diff --git a/server/project_webhook.go b/server/project_webhook.goindex f1cd261d4d..433fa65176 100644--- a/server/project_webhook.go+++ b/server/project_webhook.go@@ -58,7 +58,7 @@ func (s *Server) registerProjectWebhookRoutes(g *echo.Group) {hook, err := s.ProjectWebhookService.CreateProjectWebhook(context.Background(), hookCreate)if err != nil {- if common.ErrorCode(err) == common.ECONFLICT {+ if common.ErrorCode(err) == common.Conflict {return echo.NewHTTPError(http.StatusConflict, fmt.Sprintf("Webhook url already exists in the project: %s", hookCreate.URL))}return echo.NewHTTPError(http.StatusInternalServerError, "Failed to create project webhook").SetInternal(err)@@ -91,7 +91,7 @@ func (s *Server) registerProjectWebhookRoutes(g *echo.Group) {}hook, err := s.ProjectWebhookService.FindProjectWebhook(context.Background(), find)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Project webhook ID not found: %d", id))}return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to fetch project webhook ID: %v", id)).SetInternal(err)@@ -129,10 +129,10 @@ func (s *Server) registerProjectWebhookRoutes(g *echo.Group) {hook, err := s.ProjectWebhookService.PatchProjectWebhook(context.Background(), hookPatch)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Project webhook ID not found: %d", id))}- if common.ErrorCode(err) == common.ECONFLICT {+ if common.ErrorCode(err) == common.Conflict {return echo.NewHTTPError(http.StatusConflict, fmt.Sprintf("Hook url already exists in the project: %s", *hookPatch.URL))}return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to change project webhook ID: %v", id)).SetInternal(err)@@ -166,7 +166,7 @@ func (s *Server) registerProjectWebhookRoutes(g *echo.Group) {}err = s.ProjectWebhookService.DeleteProjectWebhook(context.Background(), hookDelete)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Project webhook ID not found: %d", id))}return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to delete project webhook ID: %v", id)).SetInternal(err)@@ -188,7 +188,7 @@ func (s *Server) registerProjectWebhookRoutes(g *echo.Group) {}project, err := s.ProjectService.FindProject(context.Background(), projectFind)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Project ID not found: %d", projectId))}return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to fetch project ID: %v", projectId)).SetInternal(err)@@ -204,7 +204,7 @@ func (s *Server) registerProjectWebhookRoutes(g *echo.Group) {}hook, err := s.ProjectWebhookService.FindProjectWebhook(context.Background(), find)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Project webhook ID not found: %d", id))}return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to fetch project webhook ID: %v", id)).SetInternal(err)diff --git a/server/setting.go b/server/setting.goindex 17fc3e7123..ac0632bc22 100644--- a/server/setting.go+++ b/server/setting.go@@ -58,7 +58,7 @@ func (s *Server) registerSettingRoutes(g *echo.Group) {setting, err := s.SettingService.PatchSetting(context.Background(), settingPatch)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Setting name not found: %s", settingPatch.Name))}return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to update setting: %v", settingPatch.Name)).SetInternal(err)diff --git a/server/sql.go b/server/sql.goindex 47e1858987..4b407f4752 100644--- a/server/sql.go+++ b/server/sql.go@@ -78,7 +78,7 @@ func (s *Server) registerSqlRoutes(g *echo.Group) {instance, err := s.ComposeInstanceById(context.Background(), sync.InstanceId)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Instance ID not found: %d", sync.InstanceId))}return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to fetch instance ID: %v", sync.InstanceId)).SetInternal(err)@@ -110,7 +110,7 @@ func (s *Server) SyncSchema(instance *api.Instance) (rs *api.SqlResultSet) {var createTable = func(database *api.Database, tableCreate *api.TableCreate) (*api.Table, error) {createTable, err := s.TableService.CreateTable(context.Background(), tableCreate)if err != nil {- if common.ErrorCode(err) == common.ECONFLICT {+ if common.ErrorCode(err) == common.Conflict {return nil, fmt.Errorf("failed to sync table for instance: %s, database: %s. Table name already exists: %s", instance.Name, database.Name, tableCreate.Name)}return nil, fmt.Errorf("failed to sync table for instance: %s, database: %s. Failed to import new table: %s. Error %w", instance.Name, database.Name, tableCreate.Name, err)@@ -121,7 +121,7 @@ func (s *Server) SyncSchema(instance *api.Instance) (rs *api.SqlResultSet) {var createColumn = func(database *api.Database, table *api.Table, columnCreate *api.ColumnCreate) error {_, err := s.ColumnService.CreateColumn(context.Background(), columnCreate)if err != nil {- if common.ErrorCode(err) == common.ECONFLICT {+ if common.ErrorCode(err) == common.Conflict {return fmt.Errorf("failed to sync column for instance: %s, database: %s, table: %s. Column name already exists: %s", instance.Name, database.Name, table.Name, columnCreate.Name)}return fmt.Errorf("failed to sync column for instance: %s, database: %s, table: %s. Failed to import new column: %s. Error %w", instance.Name, database.Name, table.Name, columnCreate.Name, err)@@ -132,7 +132,7 @@ func (s *Server) SyncSchema(instance *api.Instance) (rs *api.SqlResultSet) {var createIndex = func(database *api.Database, table *api.Table, indexCreate *api.IndexCreate) error {_, err := s.IndexService.CreateIndex(context.Background(), indexCreate)if err != nil {- if common.ErrorCode(err) == common.ECONFLICT {+ if common.ErrorCode(err) == common.Conflict {return fmt.Errorf("failed to sync index for instance: %s, database: %s, table: %s. index and expression already exists: %s(%s)", instance.Name, database.Name, table.Name, indexCreate.Name, indexCreate.Expression)}return fmt.Errorf("failed to sync index for instance: %s, database: %s, table: %s. Failed to import new index and expression: %s(%s). Error %w", instance.Name, database.Name, table.Name, indexCreate.Name, indexCreate.Expression, err)@@ -170,7 +170,7 @@ func (s *Server) SyncSchema(instance *api.Instance) (rs *api.SqlResultSet) {}_, err := s.ColumnService.FindColumn(context.Background(), columnFind)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {columnCreate := &api.ColumnCreate{CreatorId: api.SYSTEM_BOT_ID,DatabaseId: database.ID,@@ -203,7 +203,7 @@ func (s *Server) SyncSchema(instance *api.Instance) (rs *api.SqlResultSet) {}_, err := s.IndexService.FindIndex(context.Background(), indexFind)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {indexCreate := &api.IndexCreate{CreatorId: api.SYSTEM_BOT_ID,DatabaseId: database.ID,@@ -309,7 +309,7 @@ func (s *Server) SyncSchema(instance *api.Instance) (rs *api.SqlResultSet) {}database, err := s.DatabaseService.PatchDatabase(context.Background(), databasePatch)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return fmt.Errorf("failed to sync database for instance: %s. Database not found: %s", instance.Name, database.Name)}return fmt.Errorf("failed to sync database for instance: %s. Failed to update database: %s. Error %w", instance.Name, database.Name, err)@@ -345,7 +345,7 @@ func (s *Server) SyncSchema(instance *api.Instance) (rs *api.SqlResultSet) {}database, err := s.DatabaseService.CreateDatabase(context.Background(), databaseCreate)if err != nil {- if common.ErrorCode(err) == common.ECONFLICT {+ if common.ErrorCode(err) == common.Conflict {return fmt.Errorf("failed to sync database for instance: %s. Database name already exists: %s", instance.Name, databaseCreate.Name)}return fmt.Errorf("failed to sync database for instance: %s. Failed to import new database: %s. Error %w", instance.Name, databaseCreate.Name, err)@@ -380,7 +380,7 @@ func (s *Server) SyncSchema(instance *api.Instance) (rs *api.SqlResultSet) {}database, err := s.DatabaseService.PatchDatabase(context.Background(), databasePatch)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return fmt.Errorf("failed to sync database for instance: %s. Database not found: %s", instance.Name, database.Name)}return fmt.Errorf("failed to sync database for instance: %s. Failed to update database: %s. Error: %w", instance.Name, database.Name, err)diff --git a/server/task.go b/server/task.goindex 12e6072332..670b703b1f 100644--- a/server/task.go+++ b/server/task.go@@ -46,7 +46,7 @@ func (s *Server) registerTaskRoutes(g *echo.Group) {}task, err := s.TaskService.FindTask(context.Background(), taskFind)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return echo.NewHTTPError(http.StatusUnauthorized, fmt.Sprintf("Task ID not found: %d", taskId))}return echo.NewHTTPError(http.StatusInternalServerError, "Failed to update task").SetInternal(err)@@ -74,7 +74,7 @@ func (s *Server) registerTaskRoutes(g *echo.Group) {updatedTask, err := s.TaskService.PatchTask(context.Background(), taskPatch)if err != nil {- if common.ErrorCode(err) == common.EINVALID {+ if common.ErrorCode(err) == common.Invalid {return echo.NewHTTPError(http.StatusBadRequest, common.ErrorMessage(err))}return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to update task \"%v\"", task.Name)).SetInternal(err)@@ -138,7 +138,7 @@ func (s *Server) registerTaskRoutes(g *echo.Group) {}task, err := s.TaskService.FindTask(context.Background(), taskFind)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return echo.NewHTTPError(http.StatusUnauthorized, fmt.Sprintf("Task ID not found: %d", taskId))}return echo.NewHTTPError(http.StatusInternalServerError, "Failed to update task status").SetInternal(err)@@ -146,7 +146,7 @@ func (s *Server) registerTaskRoutes(g *echo.Group) {updatedTask, err := s.ChangeTaskStatusWithPatch(context.Background(), task, taskStatusPatch)if err != nil {- if common.ErrorCode(err) == common.EINVALID {+ if common.ErrorCode(err) == common.Invalid {return echo.NewHTTPError(http.StatusBadRequest, common.ErrorMessage(err))}return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to update task \"%v\" status", task.Name)).SetInternal(err)@@ -174,7 +174,7 @@ func (s *Server) registerTaskRoutes(g *echo.Group) {}task, err := s.TaskService.FindTask(context.Background(), taskFind)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return echo.NewHTTPError(http.StatusUnauthorized, fmt.Sprintf("Task ID not found: %d", taskId))}return echo.NewHTTPError(http.StatusInternalServerError, "Failed to update task status").SetInternal(err)@@ -319,7 +319,7 @@ func (s *Server) ChangeTaskStatusWithPatch(ctx context.Context, task *api.Task,if !allowTransition {return nil, &common.Error{- Code: common.EINVALID,+ Code: common.Invalid,Message: fmt.Sprintf("Invalid task status transition from %v to %v. Applicable transition(s) %v", task.Status, taskStatusPatch.Status, applicableTaskStatusTransition[task.Status])}}@@ -337,7 +337,7 @@ func (s *Server) ChangeTaskStatusWithPatch(ctx context.Context, task *api.Task,issue, err := s.IssueService.FindIssue(ctx, issueFind)if err != nil {// Not all pipelines belong to an issue, so it's OK if ENOTFOUND- if common.ErrorCode(err) != common.ENOTFOUND {+ if common.ErrorCode(err) != common.NotFound {return nil, fmt.Errorf("failed to fetch containing issue after changing the task status: %v, err: %w", task.Name, err)}}diff --git a/server/task_executor_database_restore.go b/server/task_executor_database_restore.goindex ca1b826e6d..b96da289d1 100644--- a/server/task_executor_database_restore.go+++ b/server/task_executor_database_restore.go@@ -69,7 +69,7 @@ func (exec *DatabaseRestoreTaskExecutor) RunOnce(ctx context.Context, server *Se}targetDatabase, err := server.ComposeDatabaseByFind(context.Background(), targetDatabaseFind)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return true, "", fmt.Errorf("target database %q not found in instance %q: %w", payload.DatabaseName, task.Instance.Name, err)}return true, "", fmt.Errorf("failed to find target database %q in instance %q: %w", payload.DatabaseName, task.Instance.Name, err)@@ -152,7 +152,7 @@ func createBranchMigrationHistory(ctx context.Context, server *Server, sourceDatissue, err := server.IssueService.FindIssue(ctx, issueFind)if err != nil {// Not all pipelines belong to an issue, so it's OK if ENOTFOUND- if common.ErrorCode(err) != common.ENOTFOUND {+ if common.ErrorCode(err) != common.NotFound {return fmt.Errorf("failed to fetch containing issue when creating the migration history: %v, err: %w", task.Name, err)}}diff --git a/server/vcs.go b/server/vcs.goindex 77399dd4d5..eaaaee13a6 100644--- a/server/vcs.go+++ b/server/vcs.go@@ -70,7 +70,7 @@ func (s *Server) registerVCSRoutes(g *echo.Group) {vcs, err := s.ComposeVCSById(context.Background(), id)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("VCS ID not found: %d", id))}return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to fetch vcs ID: %v", id)).SetInternal(err)@@ -99,7 +99,7 @@ func (s *Server) registerVCSRoutes(g *echo.Group) {vcs, err := s.VCSService.PatchVCS(context.Background(), vcsPatch)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("VCS ID not found: %d", id))}return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to change VCS ID: %v", id)).SetInternal(err)@@ -128,7 +128,7 @@ func (s *Server) registerVCSRoutes(g *echo.Group) {}err = s.VCSService.DeleteVCS(context.Background(), vcsDelete)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("VCS ID not found: %d", id))}return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to delete VCS ID: %v", id)).SetInternal(err)diff --git a/server/webhook.go b/server/webhook.goindex db79b69839..e98e9d9cea 100644--- a/server/webhook.go+++ b/server/webhook.go@@ -49,7 +49,7 @@ func (s *Server) registerWebhookRoutes(g *echo.Group) {}repository, err := s.RepositoryService.FindRepository(context.Background(), repositoryFind)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Endpoint not found: %v", webhookEndpointId))}return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to respond webhook event for endpoint: %v", webhookEndpointId)).SetInternal(err)diff --git a/store/activity.go b/store/activity.goindex 5a52064f60..c360d9d510 100644--- a/store/activity.go+++ b/store/activity.go@@ -75,9 +75,9 @@ func (s *ActivityService) FindActivity(ctx context.Context, find *api.ActivityFiif err != nil {return nil, err} else if len(list) == 0 {- return nil, &common.Error{Code: common.ENOTFOUND, Message: fmt.Sprintf("activity not found: %+v", find)}+ return nil, &common.Error{Code: common.NotFound, Message: fmt.Sprintf("activity not found: %+v", find)}} else if len(list) > 1 {- return nil, &common.Error{Code: common.ECONFLICT, Message: fmt.Sprintf("found %d activities with filter %+v, expect 1. ", len(list), find)}+ return nil, &common.Error{Code: common.Conflict, Message: fmt.Sprintf("found %d activities with filter %+v, expect 1. ", len(list), find)}}return list[0], nil}@@ -282,7 +282,7 @@ func patchActivity(ctx context.Context, tx *Tx, patch *api.ActivityPatch) (*api.return &activity, nil}- return nil, &common.Error{Code: common.ENOTFOUND, Message: fmt.Sprintf("activity ID not found: %d", patch.ID)}+ return nil, &common.Error{Code: common.NotFound, Message: fmt.Sprintf("activity ID not found: %d", patch.ID)}}// deleteActivity permanently deletes a activity by ID.@@ -295,7 +295,7 @@ func deleteActivity(ctx context.Context, tx *Tx, delete *api.ActivityDelete) errrows, _ := result.RowsAffected()if rows == 0 {- return &common.Error{Code: common.ENOTFOUND, Message: fmt.Sprintf("activity ID not found: %d", delete.ID)}+ return &common.Error{Code: common.NotFound, Message: fmt.Sprintf("activity ID not found: %d", delete.ID)}}return nildiff --git a/store/backup.go b/store/backup.goindex e082885b1a..4670aa9b98 100644--- a/store/backup.go+++ b/store/backup.go@@ -61,9 +61,9 @@ func (s *BackupService) FindBackup(ctx context.Context, find *api.BackupFind) (*if err != nil {return nil, err} else if len(list) == 0 {- return nil, &common.Error{Code: common.ENOTFOUND, Message: fmt.Sprintf("backup not found: %+v", find)}+ return nil, &common.Error{Code: common.NotFound, Message: fmt.Sprintf("backup not found: %+v", find)}} else if len(list) > 1 {- return nil, &common.Error{Code: common.ECONFLICT, Message: fmt.Sprintf("found %d backups with filter %+v, expect 1. ", len(list), find)}+ return nil, &common.Error{Code: common.Conflict, Message: fmt.Sprintf("found %d backups with filter %+v, expect 1. ", len(list), find)}}return list[0], nil@@ -276,7 +276,7 @@ func (s *BackupService) patchBackup(ctx context.Context, tx *Tx, patch *api.Backreturn &backup, nil}- return nil, &common.Error{Code: common.ENOTFOUND, Message: fmt.Sprintf("backup ID not found: %d", patch.ID)}+ return nil, &common.Error{Code: common.NotFound, Message: fmt.Sprintf("backup ID not found: %d", patch.ID)}}// FindBackupSetting finds the backup setting for a database.@@ -293,9 +293,9 @@ func (s *BackupService) FindBackupSetting(ctx context.Context, find *api.BackupSif err != nil {return nil, err} else if len(list) == 0 {- return nil, &common.Error{Code: common.ENOTFOUND, Message: fmt.Sprintf("backup setting not found: %+v", find)}+ return nil, &common.Error{Code: common.NotFound, Message: fmt.Sprintf("backup setting not found: %+v", find)}} else if len(list) > 1 {- return nil, &common.Error{Code: common.ECONFLICT, Message: fmt.Sprintf("found %d backup settings with filter %+v, expect 1. ", len(list), find)}+ return nil, &common.Error{Code: common.Conflict, Message: fmt.Sprintf("found %d backup settings with filter %+v, expect 1. ", len(list), find)}}return list[0], nil@@ -367,16 +367,16 @@ func (s *BackupService) UpsertBackupSetting(ctx context.Context, upsert *api.Bac// Backup plan policy check for backup setting mutation.if backupPlanPolicy.Schedule != api.BackupPlanPolicyScheduleUnset {if !upsert.Enabled {- return nil, &common.Error{Code: common.EINVALID, Message: fmt.Sprintf("backup setting should not be disabled for backup plan policy schedule %q", backupPlanPolicy.Schedule)}+ return nil, &common.Error{Code: common.Invalid, Message: fmt.Sprintf("backup setting should not be disabled for backup plan policy schedule %q", backupPlanPolicy.Schedule)}}switch backupPlanPolicy.Schedule {case api.BackupPlanPolicyScheduleDaily:if upsert.DayOfWeek != -1 {- return nil, &common.Error{Code: common.EINVALID, Message: fmt.Sprintf("backup setting DayOfWeek should be unset for backup plan policy schedule %q", backupPlanPolicy.Schedule)}+ return nil, &common.Error{Code: common.Invalid, Message: fmt.Sprintf("backup setting DayOfWeek should be unset for backup plan policy schedule %q", backupPlanPolicy.Schedule)}}case api.BackupPlanPolicyScheduleWeekly:if upsert.DayOfWeek == -1 {- return nil, &common.Error{Code: common.EINVALID, Message: fmt.Sprintf("backup setting DayOfWeek should be set for backup plan policy schedule %q", backupPlanPolicy.Schedule)}+ return nil, &common.Error{Code: common.Invalid, Message: fmt.Sprintf("backup setting DayOfWeek should be set for backup plan policy schedule %q", backupPlanPolicy.Schedule)}}}}diff --git a/store/bookmark.go b/store/bookmark.goindex 0bc217e19d..7c2a232e41 100644--- a/store/bookmark.go+++ b/store/bookmark.go@@ -75,9 +75,9 @@ func (s *BookmarkService) FindBookmark(ctx context.Context, find *api.BookmarkFiif err != nil {return nil, err} else if len(list) == 0 {- return nil, &common.Error{Code: common.ENOTFOUND, Message: fmt.Sprintf("bookmark not found: %+v", find)}+ return nil, &common.Error{Code: common.NotFound, Message: fmt.Sprintf("bookmark not found: %+v", find)}} else if len(list) > 1 {- return nil, &common.Error{Code: common.ECONFLICT, Message: fmt.Sprintf("found %d activities with filter %+v, expect 1. ", len(list), find)}+ return nil, &common.Error{Code: common.Conflict, Message: fmt.Sprintf("found %d activities with filter %+v, expect 1. ", len(list), find)}}return list[0], nil}@@ -207,7 +207,7 @@ func deleteBookmark(ctx context.Context, tx *Tx, delete *api.BookmarkDelete) errrows, _ := result.RowsAffected()if rows == 0 {- return &common.Error{Code: common.ENOTFOUND, Message: fmt.Sprintf("bookmark ID not found: %d", delete.ID)}+ return &common.Error{Code: common.NotFound, Message: fmt.Sprintf("bookmark ID not found: %d", delete.ID)}}return nildiff --git a/store/column.go b/store/column.goindex 4f7215dc2c..6277b2a61d 100644--- a/store/column.go+++ b/store/column.go@@ -76,9 +76,9 @@ func (s *ColumnService) FindColumn(ctx context.Context, find *api.ColumnFind) (*if err != nil {return nil, err} else if len(list) == 0 {- return nil, &common.Error{Code: common.ENOTFOUND, Message: fmt.Sprintf("column not found: %+v", find)}+ return nil, &common.Error{Code: common.NotFound, Message: fmt.Sprintf("column not found: %+v", find)}} else if len(list) > 1 {- return nil, &common.Error{Code: common.ECONFLICT, Message: fmt.Sprintf("found %d columns with filter %+v, expect 1", len(list), find)}+ return nil, &common.Error{Code: common.Conflict, Message: fmt.Sprintf("found %d columns with filter %+v, expect 1", len(list), find)}}return list[0], nil}@@ -313,5 +313,5 @@ func (s *ColumnService) patchColumn(ctx context.Context, tx *Tx, patch *api.Colureturn &column, nil}- return nil, &common.Error{Code: common.ENOTFOUND, Message: fmt.Sprintf("column ID not found: %d", patch.ID)}+ return nil, &common.Error{Code: common.NotFound, Message: fmt.Sprintf("column ID not found: %d", patch.ID)}}diff --git a/store/data_source.go b/store/data_source.goindex 59bc6a62af..9a986f06ce 100644--- a/store/data_source.go+++ b/store/data_source.go@@ -80,9 +80,9 @@ func (s *DataSourceService) FindDataSource(ctx context.Context, find *api.DataSoif err != nil {return nil, err} else if len(list) == 0 {- return nil, &common.Error{Code: common.ENOTFOUND, Message: fmt.Sprintf("data source not found: %+v", find)}+ return nil, &common.Error{Code: common.NotFound, Message: fmt.Sprintf("data source not found: %+v", find)}} else if len(list) > 1 {- return nil, &common.Error{Code: common.ECONFLICT, Message: fmt.Sprintf("found %d data sources with filter %+v, expect 1", len(list), find)}+ return nil, &common.Error{Code: common.Conflict, Message: fmt.Sprintf("found %d data sources with filter %+v, expect 1", len(list), find)}}return list[0], nil}@@ -272,5 +272,5 @@ func (s *DataSourceService) patchDataSource(ctx context.Context, tx *Tx, patch *return &dataSource, nil}- return nil, &common.Error{Code: common.ENOTFOUND, Message: fmt.Sprintf("dataSource ID not found: %d", patch.ID)}+ return nil, &common.Error{Code: common.NotFound, Message: fmt.Sprintf("dataSource ID not found: %d", patch.ID)}}diff --git a/store/database.go b/store/database.goindex d267a84cfb..ac03297cbc 100644--- a/store/database.go+++ b/store/database.go@@ -143,9 +143,9 @@ func (s *DatabaseService) FindDatabase(ctx context.Context, find *api.DatabaseFiif err != nil {return nil, err} else if len(list) == 0 {- return nil, &common.Error{Code: common.ENOTFOUND, Message: fmt.Sprintf("database not found: %+v", find)}+ return nil, &common.Error{Code: common.NotFound, Message: fmt.Sprintf("database not found: %+v", find)}} else if len(list) > 1 {- return nil, &common.Error{Code: common.ECONFLICT, Message: fmt.Sprintf("found %d databases with filter %+v, expect 1. ", len(list), find)}+ return nil, &common.Error{Code: common.Conflict, Message: fmt.Sprintf("found %d databases with filter %+v, expect 1. ", len(list), find)}}if err := s.cache.UpsertCache(api.DatabaseCache, list[0].ID, list[0]); err != nil {@@ -371,5 +371,5 @@ func (s *DatabaseService) patchDatabase(ctx context.Context, tx *Tx, patch *api.return &database, nil}- return nil, &common.Error{Code: common.ENOTFOUND, Message: fmt.Sprintf("database ID not found: %d", patch.ID)}+ return nil, &common.Error{Code: common.NotFound, Message: fmt.Sprintf("database ID not found: %d", patch.ID)}}diff --git a/store/environment.go b/store/environment.goindex a82838bb2c..8bc6ac30eb 100644--- a/store/environment.go+++ b/store/environment.go@@ -100,9 +100,9 @@ func (s *EnvironmentService) FindEnvironment(ctx context.Context, find *api.Enviif err != nil {return nil, err} else if len(list) == 0 {- return nil, &common.Error{Code: common.ENOTFOUND, Message: fmt.Sprintf("environment not found: %+v", find)}+ return nil, &common.Error{Code: common.NotFound, Message: fmt.Sprintf("environment not found: %+v", find)}} else if len(list) > 1 {- return nil, &common.Error{Code: common.ECONFLICT, Message: fmt.Sprintf("found %d environments with filter %+v, expect 1", len(list), find)}+ return nil, &common.Error{Code: common.Conflict, Message: fmt.Sprintf("found %d environments with filter %+v, expect 1", len(list), find)}}if err := s.cache.UpsertCache(api.EnvironmentCache, list[0].ID, list[0]); err != nil {@@ -302,5 +302,5 @@ func (s *EnvironmentService) patchEnvironment(ctx context.Context, tx *Tx, patchreturn &environment, nil}- return nil, &common.Error{Code: common.ENOTFOUND, Message: fmt.Sprintf("environment ID not found: %d", patch.ID)}+ return nil, &common.Error{Code: common.NotFound, Message: fmt.Sprintf("environment ID not found: %d", patch.ID)}}diff --git a/store/inbox.go b/store/inbox.goindex c0f9b6431e..7b957ba5ad 100644--- a/store/inbox.go+++ b/store/inbox.go@@ -77,9 +77,9 @@ func (s *InboxService) FindInbox(ctx context.Context, find *api.InboxFind) (*apiif err != nil {return nil, err} else if len(list) == 0 {- return nil, &common.Error{Code: common.ENOTFOUND, Message: fmt.Sprintf("inbox not found: %+v", find)}+ return nil, &common.Error{Code: common.NotFound, Message: fmt.Sprintf("inbox not found: %+v", find)}} else if len(list) > 1 {- return nil, &common.Error{Code: common.ECONFLICT, Message: fmt.Sprintf("found %d inboxes with filter %+v, expect 1", len(list), find)}+ return nil, &common.Error{Code: common.Conflict, Message: fmt.Sprintf("found %d inboxes with filter %+v, expect 1", len(list), find)}}return list[0], nil}@@ -315,5 +315,5 @@ func (s *InboxService) patchInbox(ctx context.Context, tx *Tx, patch *api.InboxPreturn &inbox, nil}- return nil, &common.Error{Code: common.ENOTFOUND, Message: fmt.Sprintf("inbox ID not found: %d", patch.ID)}+ return nil, &common.Error{Code: common.NotFound, Message: fmt.Sprintf("inbox ID not found: %d", patch.ID)}}diff --git a/store/instance.go b/store/instance.goindex 4476e53125..083a19e214 100644--- a/store/instance.go+++ b/store/instance.go@@ -135,9 +135,9 @@ func (s *InstanceService) FindInstance(ctx context.Context, find *api.InstanceFiif err != nil {return nil, err} else if len(list) == 0 {- return nil, &common.Error{Code: common.ENOTFOUND, Message: fmt.Sprintf("instance not found: %+v", find)}+ return nil, &common.Error{Code: common.NotFound, Message: fmt.Sprintf("instance not found: %+v", find)}} else if len(list) > 1 {- return nil, &common.Error{Code: common.ECONFLICT, Message: fmt.Sprintf("found %d instances with filter %+v, expect 1", len(list), find)}+ return nil, &common.Error{Code: common.Conflict, Message: fmt.Sprintf("found %d instances with filter %+v, expect 1", len(list), find)}}if err := s.cache.UpsertCache(api.InstanceCache, list[0].ID, list[0]); err != nil {@@ -347,5 +347,5 @@ func patchInstance(ctx context.Context, tx *Tx, patch *api.InstancePatch) (*api.return &instance, nil}- return nil, &common.Error{Code: common.ENOTFOUND, Message: fmt.Sprintf("instance ID not found: %d", patch.ID)}+ return nil, &common.Error{Code: common.NotFound, Message: fmt.Sprintf("instance ID not found: %d", patch.ID)}}diff --git a/store/instance_user.go b/store/instance_user.goindex 2b9b91ff9a..2405eac6c6 100644--- a/store/instance_user.go+++ b/store/instance_user.go@@ -179,7 +179,7 @@ func deleteInstanceUser(ctx context.Context, tx *Tx, delete *api.InstanceUserDelrows, _ := result.RowsAffected()if rows == 0 {- return &common.Error{Code: common.ENOTFOUND, Message: fmt.Sprintf("instance user ID not found: %d", delete.ID)}+ return &common.Error{Code: common.NotFound, Message: fmt.Sprintf("instance user ID not found: %d", delete.ID)}}return nildiff --git a/store/issue.go b/store/issue.goindex 4bd4eda335..631324fc18 100644--- a/store/issue.go+++ b/store/issue.go@@ -90,9 +90,9 @@ func (s *IssueService) FindIssue(ctx context.Context, find *api.IssueFind) (*apiif err != nil {return nil, err} else if len(list) == 0 {- return nil, &common.Error{Code: common.ENOTFOUND, Message: fmt.Sprintf("issue not found: %+v", find)}+ return nil, &common.Error{Code: common.NotFound, Message: fmt.Sprintf("issue not found: %+v", find)}} else if len(list) > 1 {- return nil, &common.Error{Code: common.ECONFLICT, Message: fmt.Sprintf("found %d issues with filter %+v, expect 1", len(list), find)}+ return nil, &common.Error{Code: common.Conflict, Message: fmt.Sprintf("found %d issues with filter %+v, expect 1", len(list), find)}}if err := s.cache.UpsertCache(api.IssueCache, list[0].ID, list[0]); err != nil {@@ -332,5 +332,5 @@ func (s *IssueService) patchIssue(ctx context.Context, tx *Tx, patch *api.IssuePreturn &issue, nil}- return nil, &common.Error{Code: common.ENOTFOUND, Message: fmt.Sprintf("unable to find issue ID to update: %d", patch.ID)}+ return nil, &common.Error{Code: common.NotFound, Message: fmt.Sprintf("unable to find issue ID to update: %d", patch.ID)}}diff --git a/store/issue_subscriber.go b/store/issue_subscriber.goindex f941b0f9f1..1b0d4a8b4c 100644--- a/store/issue_subscriber.go+++ b/store/issue_subscriber.go@@ -167,7 +167,7 @@ func deleteIssueSubscriber(ctx context.Context, tx *Tx, delete *api.IssueSubscrirows, _ := result.RowsAffected()if rows == 0 {- return &common.Error{Code: common.ENOTFOUND, Message: fmt.Sprintf("subscriber %d not found in issue %d", delete.SubscriberId, delete.IssueId)}+ return &common.Error{Code: common.NotFound, Message: fmt.Sprintf("subscriber %d not found in issue %d", delete.SubscriberId, delete.IssueId)}}return nildiff --git a/store/member.go b/store/member.goindex d3bc6e323a..e1a57397a5 100644--- a/store/member.go+++ b/store/member.go@@ -100,9 +100,9 @@ func (s *MemberService) FindMember(ctx context.Context, find *api.MemberFind) (*if err != nil {return nil, err} else if len(list) == 0 {- return nil, &common.Error{Code: common.ENOTFOUND, Message: fmt.Sprintf("member not found: %+v", find)}+ return nil, &common.Error{Code: common.NotFound, Message: fmt.Sprintf("member not found: %+v", find)}} else if len(list) > 1 {- return nil, &common.Error{Code: common.ECONFLICT, Message: fmt.Sprintf("found %d members with filter %+v, expect 1", len(list), find)}+ return nil, &common.Error{Code: common.Conflict, Message: fmt.Sprintf("found %d members with filter %+v, expect 1", len(list), find)}}if err := s.cache.UpsertCache(api.MemberCache, list[0].PrincipalId, list[0]); err != nil {@@ -288,5 +288,5 @@ func patchMember(ctx context.Context, tx *Tx, patch *api.MemberPatch) (*api.Membreturn &member, nil}- return nil, &common.Error{Code: common.ENOTFOUND, Message: fmt.Sprintf("member ID not found: %d", patch.ID)}+ return nil, &common.Error{Code: common.NotFound, Message: fmt.Sprintf("member ID not found: %d", patch.ID)}}diff --git a/store/pipeline.go b/store/pipeline.goindex 28919e73cf..6dcd5428b5 100644--- a/store/pipeline.go+++ b/store/pipeline.go@@ -100,9 +100,9 @@ func (s *PipelineService) FindPipeline(ctx context.Context, find *api.PipelineFiif err != nil {return nil, err} else if len(list) == 0 {- return nil, &common.Error{Code: common.ENOTFOUND, Message: fmt.Sprintf("pipeline not found: %+v", find)}+ return nil, &common.Error{Code: common.NotFound, Message: fmt.Sprintf("pipeline not found: %+v", find)}} else if len(list) > 1 {- return nil, &common.Error{Code: common.ECONFLICT, Message: fmt.Sprintf("found %d pipelines with filter %+v, expect 1", len(list), find)}+ return nil, &common.Error{Code: common.Conflict, Message: fmt.Sprintf("found %d pipelines with filter %+v, expect 1", len(list), find)}}if err := s.cache.UpsertCache(api.PipelineCache, list[0].ID, list[0]); err != nil {@@ -269,5 +269,5 @@ func (s *PipelineService) patchPipeline(ctx context.Context, tx *Tx, patch *api.return &pipeline, nil}- return nil, &common.Error{Code: common.ENOTFOUND, Message: fmt.Sprintf("pipeline ID not found: %d", patch.ID)}+ return nil, &common.Error{Code: common.NotFound, Message: fmt.Sprintf("pipeline ID not found: %d", patch.ID)}}diff --git a/store/policy.go b/store/policy.goindex 46c1fa96f4..b03c0d4fb2 100644--- a/store/policy.go+++ b/store/policy.go@@ -34,7 +34,7 @@ func (s *PolicyService) FindPolicy(ctx context.Context, find *api.PolicyFind) (*// Validate policy type existence.if find.Type != nil && *find.Type != "" {if err := api.ValidatePolicy(*find.Type, ""); err != nil {- return nil, &common.Error{Code: common.EINVALID, Message: err.Error()}+ return nil, &common.Error{Code: common.Invalid, Message: err.Error()}}}tx, err := s.db.BeginTx(ctx, nil)@@ -55,7 +55,7 @@ func (s *PolicyService) FindPolicy(ctx context.Context, find *api.PolicyFind) (*Type: *find.Type,}} else if len(list) > 1 {- return nil, &common.Error{Code: common.ECONFLICT, Message: fmt.Sprintf("found %d policy with filter %+v, expect 1. ", len(list), find)}+ return nil, &common.Error{Code: common.Conflict, Message: fmt.Sprintf("found %d policy with filter %+v, expect 1. ", len(list), find)}} else {ret = list[0]}@@ -64,7 +64,7 @@ func (s *PolicyService) FindPolicy(ctx context.Context, find *api.PolicyFind) (*// Return the default policy when there is no stored policy.payload, err := api.GetDefaultPolicy(*find.Type)if err != nil {- return nil, &common.Error{Code: common.EINTERNAL, Message: err.Error()}+ return nil, &common.Error{Code: common.Internal, Message: err.Error()}}ret.Payload = payload}@@ -134,7 +134,7 @@ func (s *PolicyService) UpsertPolicy(ctx context.Context, upsert *api.PolicyUpse// Validate policy.if upsert.Type != "" {if err := api.ValidatePolicy(upsert.Type, upsert.Payload); err != nil {- return nil, &common.Error{Code: common.EINVALID, Message: err.Error()}+ return nil, &common.Error{Code: common.Invalid, Message: err.Error()}}}tx, err := s.db.BeginTx(ctx, nil)diff --git a/store/principal.go b/store/principal.goindex 5f20576d40..7e7e6df480 100644--- a/store/principal.go+++ b/store/principal.go@@ -100,9 +100,9 @@ func (s *PrincipalService) FindPrincipal(ctx context.Context, find *api.Principaif err != nil {return nil, err} else if len(list) == 0 {- return nil, &common.Error{Code: common.ENOTFOUND, Message: fmt.Sprintf("principal not found: %+v", find)}+ return nil, &common.Error{Code: common.NotFound, Message: fmt.Sprintf("principal not found: %+v", find)}} else if len(list) > 1 {- return nil, &common.Error{Code: common.ECONFLICT, Message: fmt.Sprintf("found %d principals with filter %+v, expect 1", len(list), find)}+ return nil, &common.Error{Code: common.Conflict, Message: fmt.Sprintf("found %d principals with filter %+v, expect 1", len(list), find)}}if err := s.cache.UpsertCache(api.PrincipalCache, list[0].ID, list[0]); err != nil {@@ -286,5 +286,5 @@ func patchPrincipal(ctx context.Context, tx *Tx, patch *api.PrincipalPatch) (*apreturn &principal, nil}- return nil, &common.Error{Code: common.ENOTFOUND, Message: fmt.Sprintf("principal ID not found: %d", patch.ID)}+ return nil, &common.Error{Code: common.NotFound, Message: fmt.Sprintf("principal ID not found: %d", patch.ID)}}diff --git a/store/project.go b/store/project.goindex 53722dd9f2..43f17a630b 100644--- a/store/project.go+++ b/store/project.go@@ -101,9 +101,9 @@ func (s *ProjectService) FindProject(ctx context.Context, find *api.ProjectFind)if err != nil {return nil, err} else if len(list) == 0 {- return nil, &common.Error{Code: common.ENOTFOUND, Message: fmt.Sprintf("project not found: %+v", find)}+ return nil, &common.Error{Code: common.NotFound, Message: fmt.Sprintf("project not found: %+v", find)}} else if len(list) > 1 {- return nil, &common.Error{Code: common.ECONFLICT, Message: fmt.Sprintf("found %d projects with filter %+v, expect 1", len(list), find)}+ return nil, &common.Error{Code: common.Conflict, Message: fmt.Sprintf("found %d projects with filter %+v, expect 1", len(list), find)}}if err := s.cache.UpsertCache(api.ProjectCache, list[0].ID, list[0]); err != nil {@@ -315,5 +315,5 @@ func patchProject(ctx context.Context, tx *sql.Tx, patch *api.ProjectPatch) (*apreturn &project, nil}- return nil, &common.Error{Code: common.ENOTFOUND, Message: fmt.Sprintf("project ID not found: %d", patch.ID)}+ return nil, &common.Error{Code: common.NotFound, Message: fmt.Sprintf("project ID not found: %d", patch.ID)}}diff --git a/store/project_member.go b/store/project_member.goindex 3994fdf207..9a6d4faeba 100644--- a/store/project_member.go+++ b/store/project_member.go@@ -72,9 +72,9 @@ func (s *ProjectMemberService) FindProjectMember(ctx context.Context, find *api.if err != nil {return nil, err} else if len(list) == 0 {- return nil, &common.Error{Code: common.ENOTFOUND, Message: fmt.Sprintf("project member not found: %+v", find)}+ return nil, &common.Error{Code: common.NotFound, Message: fmt.Sprintf("project member not found: %+v", find)}} else if len(list) > 1 {- return nil, &common.Error{Code: common.ECONFLICT, Message: fmt.Sprintf("found %d project members with filter %+v, expect 1", len(list), find)}+ return nil, &common.Error{Code: common.Conflict, Message: fmt.Sprintf("found %d project members with filter %+v, expect 1", len(list), find)}}return list[0], nil}@@ -262,7 +262,7 @@ func patchProjectMember(ctx context.Context, tx *Tx, patch *api.ProjectMemberPatreturn &projectMember, nil}- return nil, &common.Error{Code: common.ENOTFOUND, Message: fmt.Sprintf("project member ID not found: %d", patch.ID)}+ return nil, &common.Error{Code: common.NotFound, Message: fmt.Sprintf("project member ID not found: %d", patch.ID)}}// deleteProjectMember permanently deletes a projectMember by ID.@@ -275,7 +275,7 @@ func deleteProjectMember(ctx context.Context, tx *Tx, delete *api.ProjectMemberDrows, _ := result.RowsAffected()if rows == 0 {- return &common.Error{Code: common.ENOTFOUND, Message: fmt.Sprintf("project member ID not found: %d", delete.ID)}+ return &common.Error{Code: common.NotFound, Message: fmt.Sprintf("project member ID not found: %d", delete.ID)}}return nildiff --git a/store/project_webhook.go b/store/project_webhook.goindex c0c908ca1c..534953a37d 100644--- a/store/project_webhook.go+++ b/store/project_webhook.go@@ -75,9 +75,9 @@ func (s *ProjectWebhookService) FindProjectWebhook(ctx context.Context, find *apif err != nil {return nil, err} else if len(list) == 0 {- return nil, &common.Error{Code: common.ENOTFOUND, Message: fmt.Sprintf("project hook not found: %+v", find)}+ return nil, &common.Error{Code: common.NotFound, Message: fmt.Sprintf("project hook not found: %+v", find)}} else if len(list) > 1 {- return nil, &common.Error{Code: common.ECONFLICT, Message: fmt.Sprintf("found %d project hooks with filter %+v, expect 1", len(list), find)}+ return nil, &common.Error{Code: common.Conflict, Message: fmt.Sprintf("found %d project hooks with filter %+v, expect 1", len(list), find)}}return list[0], nil}@@ -298,7 +298,7 @@ func patchProjectWebhook(ctx context.Context, tx *Tx, patch *api.ProjectWebhookPreturn &projectWebhook, nil}- return nil, &common.Error{Code: common.ENOTFOUND, Message: fmt.Sprintf("project hook ID not found: %d", patch.ID)}+ return nil, &common.Error{Code: common.NotFound, Message: fmt.Sprintf("project hook ID not found: %d", patch.ID)}}// deleteProjectWebhook permanently deletes a projectWebhook by ID.@@ -311,7 +311,7 @@ func deleteProjectWebhook(ctx context.Context, tx *Tx, delete *api.ProjectWebhoorows, _ := result.RowsAffected()if rows == 0 {- return &common.Error{Code: common.ENOTFOUND, Message: fmt.Sprintf("project hook ID not found: %d", delete.ID)}+ return &common.Error{Code: common.NotFound, Message: fmt.Sprintf("project hook ID not found: %d", delete.ID)}}return nildiff --git a/store/repository.go b/store/repository.goindex 41f7be63b8..767aa5218c 100644--- a/store/repository.go+++ b/store/repository.go@@ -77,9 +77,9 @@ func (s *RepositoryService) FindRepository(ctx context.Context, find *api.Reposiif err != nil {return nil, err} else if len(list) == 0 {- return nil, &common.Error{Code: common.ENOTFOUND, Message: fmt.Sprintf("repository not found: %+v", find)}+ return nil, &common.Error{Code: common.NotFound, Message: fmt.Sprintf("repository not found: %+v", find)}} else if len(list) > 1 {- return nil, &common.Error{Code: common.ECONFLICT, Message: fmt.Sprintf("found %d repositories with filter %+v, expect 1", len(list), find)}+ return nil, &common.Error{Code: common.Conflict, Message: fmt.Sprintf("found %d repositories with filter %+v, expect 1", len(list), find)}}return list[0], nil}@@ -377,7 +377,7 @@ func patchRepository(ctx context.Context, tx *Tx, patch *api.RepositoryPatch) (*return &repository, nil}- return nil, &common.Error{Code: common.ENOTFOUND, Message: fmt.Sprintf("repository ID not found: %d", patch.ID)}+ return nil, &common.Error{Code: common.NotFound, Message: fmt.Sprintf("repository ID not found: %d", patch.ID)}}// deleteRepository permanently deletes a repository by ID.@@ -401,7 +401,7 @@ func (s *RepositoryService) deleteRepository(ctx context.Context, tx *Tx, deleterows, _ := result.RowsAffected()if rows == 0 {- return &common.Error{Code: common.ENOTFOUND, Message: fmt.Sprintf("repository not found for project ID: %d", delete.ProjectId)}+ return &common.Error{Code: common.NotFound, Message: fmt.Sprintf("repository not found for project ID: %d", delete.ProjectId)}}return nildiff --git a/store/setting.go b/store/setting.goindex 82a1e77508..daba72fbdd 100644--- a/store/setting.go+++ b/store/setting.go@@ -34,7 +34,7 @@ func (s *SettingService) CreateSettingIfNotExist(ctx context.Context, create *ap}setting, err := s.FindSetting(ctx, find)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {tx, err := s.db.BeginTx(ctx, nil)if err != nil {return nil, FormatError(err)@@ -87,9 +87,9 @@ func (s *SettingService) FindSetting(ctx context.Context, find *api.SettingFind)if err != nil {return nil, err} else if len(list) == 0 {- return nil, &common.Error{Code: common.ENOTFOUND, Message: fmt.Sprintf("setting not found: %+v", find)}+ return nil, &common.Error{Code: common.NotFound, Message: fmt.Sprintf("setting not found: %+v", find)}} else if len(list) > 1 {- return nil, &common.Error{Code: common.ECONFLICT, Message: fmt.Sprintf("found %d activities with filter %+v, expect 1. ", len(list), find)}+ return nil, &common.Error{Code: common.Conflict, Message: fmt.Sprintf("found %d activities with filter %+v, expect 1. ", len(list), find)}}return list[0], nil}@@ -243,5 +243,5 @@ func patchSetting(ctx context.Context, tx *Tx, patch *api.SettingPatch) (*api.Sereturn &setting, nil}- return nil, &common.Error{Code: common.ENOTFOUND, Message: fmt.Sprintf("setting not found: %s", patch.Name)}+ return nil, &common.Error{Code: common.NotFound, Message: fmt.Sprintf("setting not found: %s", patch.Name)}}diff --git a/store/sqlite.go b/store/sqlite.goindex 45da705ef7..b10a221bfa 100644--- a/store/sqlite.go+++ b/store/sqlite.go@@ -334,29 +334,29 @@ func FormatError(err error) error {switch err.Error() {case "UNIQUE constraint failed: principal.email":- return common.Errorf(common.ECONFLICT, "email already exists")+ return common.Errorf(common.Conflict, "email already exists")case "UNIQUE constraint failed: member.principal_id":- return common.Errorf(common.ECONFLICT, "member already exists")+ return common.Errorf(common.Conflict, "member already exists")case "UNIQUE constraint failed: environment.name":- return common.Errorf(common.ECONFLICT, "environment name already exists")+ return common.Errorf(common.Conflict, "environment name already exists")case "UNIQUE constraint failed: project.key":- return common.Errorf(common.ECONFLICT, "project key already exists")+ return common.Errorf(common.Conflict, "project key already exists")case "UNIQUE constraint failed: project_webhook.project_id, project_webhook.url":- return common.Errorf(common.ECONFLICT, "webhook url already exists")+ return common.Errorf(common.Conflict, "webhook url already exists")case "UNIQUE constraint failed: project_member.project_id, project_member.principal_id":- return common.Errorf(common.ECONFLICT, "project member already exists")+ return common.Errorf(common.Conflict, "project member already exists")case "UNIQUE constraint failed: db.instance_id, db.name":- return common.Errorf(common.ECONFLICT, "database name already exists")+ return common.Errorf(common.Conflict, "database name already exists")case "UNIQUE constraint failed: data_source.instance_id, data_source.name":- return common.Errorf(common.ECONFLICT, "data source name already exists")+ return common.Errorf(common.Conflict, "data source name already exists")case "UNIQUE constraint failed: backup.database_id, backup.name":- return common.Errorf(common.ECONFLICT, "backup name already exists")+ return common.Errorf(common.Conflict, "backup name already exists")case "UNIQUE constraint failed: bookmark.creator_id, bookmark.link":- return common.Errorf(common.ECONFLICT, "bookmark already exists")+ return common.Errorf(common.Conflict, "bookmark already exists")case "UNIQUE constraint failed: repository.project_id":- return common.Errorf(common.ECONFLICT, "project has already linked repository")+ return common.Errorf(common.Conflict, "project has already linked repository")case "UNIQUE constraint failed: issue_subscriber.issue_id, issue_subscriber.subscriber_id":- return common.Errorf(common.ECONFLICT, "issue subscriber already exists")+ return common.Errorf(common.Conflict, "issue subscriber already exists")default:return err}diff --git a/store/stage.go b/store/stage.goindex 08205e8c02..fcc7cbb4f4 100644--- a/store/stage.go+++ b/store/stage.go@@ -75,9 +75,9 @@ func (s *StageService) FindStage(ctx context.Context, find *api.StageFind) (*apiif err != nil {return nil, err} else if len(list) == 0 {- return nil, &common.Error{Code: common.ENOTFOUND, Message: fmt.Sprintf("stage not found: %+v", find)}+ return nil, &common.Error{Code: common.NotFound, Message: fmt.Sprintf("stage not found: %+v", find)}} else if len(list) > 1 {- return nil, &common.Error{Code: common.ECONFLICT, Message: fmt.Sprintf("found %d stages with filter %+v, expect 1", len(list), find)}+ return nil, &common.Error{Code: common.Conflict, Message: fmt.Sprintf("found %d stages with filter %+v, expect 1", len(list), find)}}return list[0], nil}diff --git a/store/table.go b/store/table.goindex 30e84765b3..6c18206a0c 100644--- a/store/table.go+++ b/store/table.go@@ -75,9 +75,9 @@ func (s *TableService) FindTable(ctx context.Context, find *api.TableFind) (*apiif err != nil {return nil, err} else if len(list) == 0 {- return nil, &common.Error{Code: common.ENOTFOUND, Message: fmt.Sprintf("table not found: %+v", find)}+ return nil, &common.Error{Code: common.NotFound, Message: fmt.Sprintf("table not found: %+v", find)}} else if len(list) > 1 {- return nil, &common.Error{Code: common.ECONFLICT, Message: fmt.Sprintf("found %d tables with filter %+v, expect 1", len(list), find)}+ return nil, &common.Error{Code: common.Conflict, Message: fmt.Sprintf("found %d tables with filter %+v, expect 1", len(list), find)}}return list[0], nil}@@ -312,7 +312,7 @@ func (s *TableService) patchTable(ctx context.Context, tx *Tx, patch *api.TablePreturn &table, nil}- return nil, &common.Error{Code: common.ENOTFOUND, Message: fmt.Sprintf("table ID not found: %d", patch.ID)}+ return nil, &common.Error{Code: common.NotFound, Message: fmt.Sprintf("table ID not found: %d", patch.ID)}}// deleteTable permanently deletes tables from a database.diff --git a/store/table_index.go b/store/table_index.goindex 791d8d6308..634b45bdad 100644--- a/store/table_index.go+++ b/store/table_index.go@@ -75,9 +75,9 @@ func (s *IndexService) FindIndex(ctx context.Context, find *api.IndexFind) (*apiif err != nil {return nil, err} else if len(list) == 0 {- return nil, &common.Error{Code: common.ENOTFOUND, Message: fmt.Sprintf("index not found: %+v", find)}+ return nil, &common.Error{Code: common.NotFound, Message: fmt.Sprintf("index not found: %+v", find)}} else if len(list) > 1 {- return nil, &common.Error{Code: common.ECONFLICT, Message: fmt.Sprintf("found %d indexs with filter %+v, expect 1", len(list), find)}+ return nil, &common.Error{Code: common.Conflict, Message: fmt.Sprintf("found %d indexs with filter %+v, expect 1", len(list), find)}}return list[0], nil}@@ -287,5 +287,5 @@ func (s *IndexService) patchIndex(ctx context.Context, tx *Tx, patch *api.IndexPreturn &index, nil}- return nil, &common.Error{Code: common.ENOTFOUND, Message: fmt.Sprintf("index ID not found: %d", patch.ID)}+ return nil, &common.Error{Code: common.NotFound, Message: fmt.Sprintf("index ID not found: %d", patch.ID)}}diff --git a/store/task.go b/store/task.goindex e57b0df159..7cfe0c8ccd 100644--- a/store/task.go+++ b/store/task.go@@ -223,9 +223,9 @@ func (s *TaskService) findTask(ctx context.Context, tx *Tx, find *api.TaskFind)if err != nil {return nil, err} else if len(list) == 0 {- return nil, &common.Error{Code: common.ENOTFOUND, Message: fmt.Sprintf("task not found: %+v", find)}+ return nil, &common.Error{Code: common.NotFound, Message: fmt.Sprintf("task not found: %+v", find)}} else if len(list) > 1 {- return nil, &common.Error{Code: common.ECONFLICT, Message: fmt.Sprintf("found %d tasks with filter %+v, expect 1", len(list), find)}+ return nil, &common.Error{Code: common.Conflict, Message: fmt.Sprintf("found %d tasks with filter %+v, expect 1", len(list), find)}}return list[0], nil}@@ -367,7 +367,7 @@ func (s *TaskService) patchTask(ctx context.Context, tx *Tx, patch *api.TaskPatcreturn &task, nil}- return nil, &common.Error{Code: common.ENOTFOUND, Message: fmt.Sprintf("task ID not found: %d", patch.ID)}+ return nil, &common.Error{Code: common.NotFound, Message: fmt.Sprintf("task ID not found: %d", patch.ID)}}// patchTaskStatus updates a task status by ID. Returns the new state of the task after update.@@ -392,7 +392,7 @@ func (s *TaskService) patchTaskStatus(ctx context.Context, tx *Tx, patch *api.Ta}taskRun, err := s.TaskRunService.FindTaskRunTx(ctx, tx.Tx, taskRunFind)if err != nil {- if common.ErrorCode(err) == common.ENOTFOUND {+ if common.ErrorCode(err) == common.NotFound {if patch.Status != api.TaskRunning {return nil, fmt.Errorf("no applicable running task to change status")}@@ -496,5 +496,5 @@ func (s *TaskService) patchTaskStatus(ctx context.Context, tx *Tx, patch *api.Tareturn &task, nil}- return nil, &common.Error{Code: common.ENOTFOUND, Message: fmt.Sprintf("task ID not found: %d", patch.ID)}+ return nil, &common.Error{Code: common.NotFound, Message: fmt.Sprintf("task ID not found: %d", patch.ID)}}diff --git a/store/task_check_run.go b/store/task_check_run.goindex e257e03653..e555b651bb 100644--- a/store/task_check_run.go+++ b/store/task_check_run.go@@ -172,9 +172,9 @@ func (s *TaskCheckRunService) FindTaskCheckRunTx(ctx context.Context, tx *sql.Txif err != nil {return nil, err} else if len(list) == 0 {- return nil, &common.Error{Code: common.ENOTFOUND, Message: fmt.Sprintf("task run not found: %+v", find)}+ return nil, &common.Error{Code: common.NotFound, Message: fmt.Sprintf("task run not found: %+v", find)}} else if len(list) > 1 {- return nil, &common.Error{Code: common.ECONFLICT, Message: fmt.Sprintf("found %d task runs with filter %+v, expect 1", len(list), find)}+ return nil, &common.Error{Code: common.Conflict, Message: fmt.Sprintf("found %d task runs with filter %+v, expect 1", len(list), find)}}return list[0], nil}diff --git a/store/task_run.go b/store/task_run.goindex 380d26ebed..d494092400 100644--- a/store/task_run.go+++ b/store/task_run.go@@ -93,9 +93,9 @@ func (s *TaskRunService) FindTaskRunTx(ctx context.Context, tx *sql.Tx, find *apif err != nil {return nil, err} else if len(list) == 0 {- return nil, &common.Error{Code: common.ENOTFOUND, Message: fmt.Sprintf("task run not found: %+v", find)}+ return nil, &common.Error{Code: common.NotFound, Message: fmt.Sprintf("task run not found: %+v", find)}} else if len(list) > 1 {- return nil, &common.Error{Code: common.ECONFLICT, Message: fmt.Sprintf("found %d task runs with filter %+v, expect 1", len(list), find)}+ return nil, &common.Error{Code: common.Conflict, Message: fmt.Sprintf("found %d task runs with filter %+v, expect 1", len(list), find)}}return list[0], nil}diff --git a/store/vcs.go b/store/vcs.goindex 9b4a392cda..76c33cdf29 100644--- a/store/vcs.go+++ b/store/vcs.go@@ -75,9 +75,9 @@ func (s *VCSService) FindVCS(ctx context.Context, find *api.VCSFind) (*api.VCS,if err != nil {return nil, err} else if len(list) == 0 {- return nil, &common.Error{Code: common.ENOTFOUND, Message: fmt.Sprintf("vcs not found: %+v", find)}+ return nil, &common.Error{Code: common.NotFound, Message: fmt.Sprintf("vcs not found: %+v", find)}} else if len(list) > 1 {- return nil, &common.Error{Code: common.ECONFLICT, Message: fmt.Sprintf("found %d vcss with filter %+v, expect 1", len(list), find)}+ return nil, &common.Error{Code: common.Conflict, Message: fmt.Sprintf("found %d vcss with filter %+v, expect 1", len(list), find)}}return list[0], nil}@@ -285,7 +285,7 @@ func patchVCS(ctx context.Context, tx *Tx, patch *api.VCSPatch) (*api.VCS, errorreturn &vcs, nil}- return nil, &common.Error{Code: common.ENOTFOUND, Message: fmt.Sprintf("vcs ID not found: %d", patch.ID)}+ return nil, &common.Error{Code: common.NotFound, Message: fmt.Sprintf("vcs ID not found: %d", patch.ID)}}// deleteVCS permanently deletes a vcs by ID.@@ -298,7 +298,7 @@ func deleteVCS(ctx context.Context, tx *Tx, delete *api.VCSDelete) error {rows, _ := result.RowsAffected()if rows == 0 {- return &common.Error{Code: common.ENOTFOUND, Message: fmt.Sprintf("vcs ID not found: %d", delete.ID)}+ return &common.Error{Code: common.NotFound, Message: fmt.Sprintf("vcs ID not found: %d", delete.ID)}}return nil