mirror of
https://github.com/go-gitea/gitea.git
synced 2024-05-11 05:55:29 +00:00
Check webhooks slice length before calling xorm (#20642)
xorm.db.Insert errors for empty slices. Fixes: #20641 Co-authored-by: Lauris BH <[email protected]> Co-authored-by: John Olheiser <[email protected]> Co-authored-by: Lunny Xiao <[email protected]>
This commit is contained in:
co-authored by
Lauris BH
John Olheiser
Lunny Xiao
parent
6c218f7a5c
commit
cf06e20c0d
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user