diff --git a/services/repository/template.go b/services/repository/template.go index a16284688b..b73abdce58 100644 --- a/services/repository/template.go +++ b/services/repository/template.go @@ -21,6 +21,11 @@ func GenerateIssueLabels(ctx context.Context, templateRepo, generateRepo *repo_m if err != nil { return err } + // Prevent insert being called with an empty slice which would result in + // err "no element on slice when insert". + if len(templateLabels) == 0 { + return nil + } newLabels := make([]*issues_model.Label, 0, len(templateLabels)) for _, templateLabel := range templateLabels {