Skip to content

Commit cf06e20

Browse files
gabriel-vasilelafriksjolheiserlunny
authored
Check webhooks slice length before calling xorm (#20642)
xorm.db.Insert errors for empty slices. Fixes: #20641 Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: John Olheiser <john.olheiser@gmail.com> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
1 parent 6c218f7 commit cf06e20

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

models/webhook/webhook.go

+4
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)