Validate max_retries on both target forms (closes #221)
All checks were successful
check / check (push) Successful in 3m36s
All checks were successful
check / check (push) Successful in 3m36s
This commit was merged in pull request #259.
This commit is contained in:
@@ -133,20 +133,28 @@ func (h *Handlers) applyTargetEdit(
|
||||
return
|
||||
}
|
||||
|
||||
target.Name = name
|
||||
target.Config = configJSON
|
||||
|
||||
// Retries are offered only by the forms for target types that
|
||||
// retry, so an absent field means "this form does not edit
|
||||
// retries" rather than "set them to zero". Reading it
|
||||
// unconditionally would silently disable retries on any target
|
||||
// saved from a form that does not render the input.
|
||||
//
|
||||
// A field that IS submitted but does not parse is a 400, through
|
||||
// the same validator the create path uses. It is rejected before
|
||||
// anything is written, so a typo cannot destroy the retry count
|
||||
// the target is already delivering with.
|
||||
if r.PostForm.Has("max_retries") {
|
||||
target.MaxRetries = parseNonNegativeInt(
|
||||
r.PostFormValue("max_retries"),
|
||||
)
|
||||
retries, ok := targetMaxRetries(w, r, target.MaxRetries)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
target.MaxRetries = retries
|
||||
}
|
||||
|
||||
target.Name = name
|
||||
target.Config = configJSON
|
||||
|
||||
err = h.db.DB().Save(target).Error
|
||||
if err != nil {
|
||||
h.serverError(w, "failed to update target", err)
|
||||
|
||||
Reference in New Issue
Block a user