mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-27 14:39:40 -08:00
query_range: Validate that start comes before end
This commit is contained in:
parent
e3d7c39529
commit
5c025a2f41
|
@ -182,6 +182,11 @@ func (api *API) queryRange(r *http.Request) (interface{}, *apiError) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, &apiError{errorBadData, err}
|
return nil, &apiError{errorBadData, err}
|
||||||
}
|
}
|
||||||
|
if end.Before(start) {
|
||||||
|
err := errors.New("end timestamp must not be before start time")
|
||||||
|
return nil, &apiError{errorBadData, err}
|
||||||
|
}
|
||||||
|
|
||||||
step, err := parseDuration(r.FormValue("step"))
|
step, err := parseDuration(r.FormValue("step"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, &apiError{errorBadData, err}
|
return nil, &apiError{errorBadData, err}
|
||||||
|
|
|
@ -198,6 +198,17 @@ func TestEndpoints(t *testing.T) {
|
||||||
},
|
},
|
||||||
errType: errorBadData,
|
errType: errorBadData,
|
||||||
},
|
},
|
||||||
|
// Start after end
|
||||||
|
{
|
||||||
|
endpoint: api.queryRange,
|
||||||
|
query: url.Values{
|
||||||
|
"query": []string{"time()"},
|
||||||
|
"start": []string{"2"},
|
||||||
|
"end": []string{"1"},
|
||||||
|
"step": []string{"1"},
|
||||||
|
},
|
||||||
|
errType: errorBadData,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
endpoint: api.labelValues,
|
endpoint: api.labelValues,
|
||||||
params: map[string]string{
|
params: map[string]string{
|
||||||
|
|
Loading…
Reference in a new issue