Skip to content

Commit b43d7e1

Browse files
zeripathgabriel-vasile6543lafrikstechknowlogick
authored
Check issue labels slice length before calling xorm Insert(#20655) (#20836)
Backport #20655 Fix #20654 Co-authored-by: Gabriel Vasile <[email protected]> Co-authored-by: 6543 <[email protected]> Co-authored-by: Lauris BH <[email protected]> Co-authored-by: techknowlogick <[email protected]>
1 parent 987798a commit b43d7e1

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

services/repository/template.go

+5
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ func GenerateIssueLabels(ctx context.Context, templateRepo, generateRepo *repo_m
2121
if err != nil {
2222
return err
2323
}
24+
// Prevent insert being called with an empty slice which would result in
25+
// err "no element on slice when insert".
26+
if len(templateLabels) == 0 {
27+
return nil
28+
}
2429

2530
newLabels := make([]*issues_model.Label, 0, len(templateLabels))
2631
for _, templateLabel := range templateLabels {

0 commit comments

Comments
 (0)