Merge pull request #2142 from amorken/issue-2140

query_range: Validate that start comes before end
This commit is contained in:
Fabian Reinartz 2016-11-01 15:40:07 +01:00 committed by GitHub
commit 6875e9ef91
2 changed files with 16 additions and 0 deletions

View File

@ -182,6 +182,11 @@ func (api *API) queryRange(r *http.Request) (interface{}, *apiError) {
if err != nil {
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"))
if err != nil {
return nil, &apiError{errorBadData, err}

View File

@ -198,6 +198,17 @@ func TestEndpoints(t *testing.T) {
},
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,
params: map[string]string{