Skip to content

Commit

Permalink
Check webhooks slice length before calling xorm (#20642) (#20768)
Browse files Browse the repository at this point in the history
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>
Co-authored-by: Gabriel Vasile <gabriel.vasile@email.com>
  • Loading branch information
4 people authored Aug 12, 2022
1 parent f7c874c commit ac9792c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions models/webhook/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,10 @@ func CreateWebhook(ctx context.Context, w *Webhook) error {

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

0 comments on commit ac9792c

Please sign in to comment.