Skip to content

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

chore(assignee-group): update comment (#2260)

p0nycc294caccd66
diff --git a/api/policy.go b/api/policy.go
index 85eee8d8f6..59f1a51a1e 100644
--- a/api/policy.go
+++ b/api/policy.go
@@ -123,9 +123,9 @@ type PolicyDelete struct {
// PipelineApprovalPolicy is the policy configuration for pipeline approval.
type PipelineApprovalPolicy struct {
Value PipelineApprovalValue `json:"value"`
- // if the approval policy is MANUAL_APPROVAL_NEVER, there shouldn't be AssigneeGroupList.
- // if the approval policy is MANUAL_APPROVAL_ALWAYS, the assignee group is the DBAs by default,
- // and we set the assignee group to the project owners for corresponding issue types.
+ // The AssigneeGroup is the final value of the assignee group which overrides the default value.
+ // If there is no value provided in the AssigneeGroupList, we use the the workspace owners and DBAs (default) as the available assignee.
+ // If the AssigneeGroupValue is PROJECT_OWNER, the available assignee is the project owners.
AssigneeGroupList []AssigneeGroup `json:"assigneeGroupList"`
}
diff --git a/server/task.go b/server/task.go
index 289f484607..6f87248f4a 100644
--- a/server/task.go
+++ b/server/task.go
@@ -497,6 +497,7 @@ func (s *Server) patchTask(ctx context.Context, task *api.Task, taskPatch *api.T
return taskPatched, nil
}
+// canPrincipalBeAssignee checks if a principal could be the assignee of an issue, judging by the principal role and the environment policy.
func (s *Server) canPrincipalBeAssignee(ctx context.Context, principalID int, environmentID int, projectID int, issueType api.IssueType) (bool, error) {
policy, err := s.store.GetPipelineApprovalPolicy(ctx, environmentID)
if err != nil {
@@ -510,8 +511,8 @@ func (s *Server) canPrincipalBeAssignee(ctx context.Context, principalID int, en
}
}
if groupValue == nil {
- // default
- // the assignee group is the workspace owner and DBA role.
+ // no value is set, fallback to default.
+ // the assignee group is the workspace owner and DBA.
principal, err := s.store.GetPrincipalByID(ctx, principalID)
if err != nil {
return false, common.Errorf(common.Internal, "failed to get principal by ID %d, error: %w", principalID, err)
@@ -523,7 +524,7 @@ func (s *Server) canPrincipalBeAssignee(ctx context.Context, principalID int, en
return true, nil
}
} else if *groupValue == api.AssigneeGroupValueProjectOwner {
- // as the policy says, the assignee group is the project owner.
+ // the assignee group is the project owner.
member, err := s.store.GetProjectMember(ctx, &api.ProjectMemberFind{
ProjectID: &projectID,
PrincipalID: &principalID,
@@ -531,7 +532,10 @@ func (s *Server) canPrincipalBeAssignee(ctx context.Context, principalID int, en
if err != nil {
return false, common.Errorf(common.Internal, "failed to get project member by projectID %d, principalID %d, error: %w", projectID, principalID, err)
}
- if member != nil && member.Role == string(api.Owner) {
+ if member == nil {
+ return false, common.Errorf(common.NotFound, "project member not found by projectID %d, principalID %d", projectID, principalID)
+ }
+ if member.Role == string(api.Owner) {
return true, nil
}
}