Skip to content

Commit ac9792c

Browse files
lunnylafriksjolheisergabriel-vasile
authored
Check webhooks slice length before calling xorm (#20642) (#20768)
Fixes: #20641 Co-authored-by: Lauris BH <[email protected]> Co-authored-by: John Olheiser <[email protected]> Co-authored-by: Lunny Xiao <[email protected]> Co-authored-by: Gabriel Vasile <[email protected]>
1 parent f7c874c commit ac9792c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

models/webhook/webhook.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,10 @@ func CreateWebhook(ctx context.Context, w *Webhook) error {
399399

400400
// CreateWebhooks creates multiple web hooks
401401
func CreateWebhooks(ctx context.Context, ws []*Webhook) error {
402+
// xorm returns err "no element on slice when insert" for empty slices.
403+
if len(ws) == 0 {
404+
return nil
405+
}
402406
for i := 0; i < len(ws); i++ {
403407
ws[i].Type = strings.TrimSpace(ws[i].Type)
404408
}

0 commit comments

Comments
 (0)