lib/httputils: handle step=undefined query arg as an empty value

This is needed for Grafana, which may send step=undefined
when working with alerting rules and instant queries.
This commit is contained in:
Aliaksandr Valialkin 2024-01-16 18:58:29 +02:00
parent 94a17d792d
commit 25564e66e6
No known key found for this signature in database
GPG key ID: 52C003EE2BCDB9EB

View file

@ -14,6 +14,10 @@ func GetDuration(r *http.Request, argKey string, defaultValue int64) (int64, err
if len(argValue) == 0 {
return defaultValue, nil
}
if argValue == "undefined" {
// This hack is needed for Grafana, which may send undefined value
return defaultValue, nil
}
secs, err := strconv.ParseFloat(argValue, 64)
if err != nil {
// Try parsing string format