Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
feat: find a more appropriate assignee than the system bot (#2336)
p0nye309e985222c
diff --git a/server/issue.go b/server/issue.goindex 9dbd927da6..998a3f1719 100644--- a/server/issue.go+++ b/server/issue.go@@ -266,20 +266,23 @@ func (s *Server) createIssue(ctx context.Context, issueCreate *api.IssueCreate,return nil, err}- // validate the assignee if we are going to actually create the issue (NOT ValidateOnly).- if !issueCreate.ValidateOnly {- // pipeline generation logic was moved to the backend, so the frontend needs to get the generated pipeline first in order to send a user-filled issue back.- // ValidateOnly means that we merely generate issue for the frontend so there is no need to check the assignee since it's a dummy value and will be set by the user later.- if issueCreate.AssigneeID == api.UnknownID {- return nil, echo.NewHTTPError(http.StatusBadRequest, "Failed to create issue, assignee missing")- }- ok, err := s.canPrincipalBeAssignee(ctx, issueCreate.AssigneeID, pipelineCreate.StageList[0].EnvironmentID, issueCreate.ProjectID, issueCreate.Type)+ if issueCreate.AssigneeID == api.UnknownID {+ return nil, echo.NewHTTPError(http.StatusBadRequest, "Failed to create issue, assignee missing")+ }+ // Try to find a more appropriate assignee if the current assignee is the system bot, indicating that the caller might not be sure about who should be the assignee.+ if issueCreate.AssigneeID == api.SystemBotID {+ assigneeID, err := s.getDefaultAssigneeID(ctx, pipelineCreate.StageList[0].EnvironmentID, issueCreate.ProjectID, issueCreate.Type)if err != nil {- return nil, echo.NewHTTPError(http.StatusInternalServerError, "Failed to check if the assignee can be set for the new issue").SetInternal(err)- }- if !ok {- return nil, echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Cannot set assignee with user id %d", issueCreate.AssigneeID))+ return nil, echo.NewHTTPError(http.StatusInternalServerError, "Failed to find a default assignee").SetInternal(err)}+ issueCreate.AssigneeID = assigneeID+ }+ ok, err := s.canPrincipalBeAssignee(ctx, issueCreate.AssigneeID, pipelineCreate.StageList[0].EnvironmentID, issueCreate.ProjectID, issueCreate.Type)+ if err != nil {+ return nil, echo.NewHTTPError(http.StatusInternalServerError, "Failed to check if the assignee can be set for the new issue").SetInternal(err)+ }+ if !ok {+ return nil, echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Cannot set assignee with user id %d", issueCreate.AssigneeID))}pipeline, err := s.createPipeline(ctx, issueCreate, pipelineCreate, creatorID)