Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
* [BUGFIX] metrics-generator: Fix active-series counter underflow in local series limiter when overflow series are deleted [#6568](https://github.com/grafana/tempo/pull/6568) (@carles-grafana)
* [BUGFIX] fix: skip per-label limiter and sanitizer for target_info and host_info metrics in metrics-generator [#6660](https://github.com/grafana/tempo/pull/6660) (@electron0zero)
* [BUGFIX] fix(traceql): err on division by zero [#6580](https://github.com/grafana/tempo/pull/6580) (@Proximyst)
* [BUGFIX] Return 400 instead of 500 when query_range or query_instant requests have unparseable start/end parameters [#6694](https://github.com/grafana/tempo/pull/6694) (@ruslan-mikhailov)

### 3.0 Cleanup

Expand Down
10 changes: 8 additions & 2 deletions pkg/api/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,10 @@ func ParseQueryInstantRequest(r *http.Request) (*tempopb.QueryInstantRequest, er
req.Query = s
}

start, end, _ := bounds(vals)
start, end, err := bounds(vals)
if err != nil {
return nil, httpgrpc.Error(http.StatusBadRequest, err.Error())
}
req.Start = uint64(start.UnixNano())
req.End = uint64(end.UnixNano())

Expand All @@ -329,7 +332,10 @@ func ParseQueryRangeRequest(r *http.Request) (*tempopb.QueryRangeRequest, error)
req.QueryMode = s
}

start, end, _ := bounds(vals)
start, end, err := bounds(vals)
if err != nil {
return nil, httpgrpc.Error(http.StatusBadRequest, err.Error())
}
req.Start = uint64(start.UnixNano())
req.End = uint64(end.UnixNano())

Expand Down
35 changes: 35 additions & 0 deletions pkg/api/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,41 @@ func Test_parseTimestamp(t *testing.T) {
}
}

func TestParseQueryRequestInvalidBounds(t *testing.T) {
tests := []struct {
name string
params map[string]string
errMsg string
}{
{
name: "invalid start",
params: map[string]string{"q": "{} | rate()", "start": "abc", "end": "1700000000"},
errMsg: "could not parse 'start' parameter",
},
{
name: "invalid end",
params: map[string]string{"q": "{} | rate()", "start": "1700000000", "end": "bca"},
errMsg: "could not parse 'end' parameter",
},
}

for _, tt := range tests {
t.Run("range/"+tt.name, func(t *testing.T) {
r := makeReq(tt.params)
_, err := ParseQueryRangeRequest(r)
require.Error(t, err)
assert.Contains(t, err.Error(), tt.errMsg)
})

t.Run("instant/"+tt.name, func(t *testing.T) {
r := makeReq(tt.params)
_, err := ParseQueryInstantRequest(r)
require.Error(t, err)
assert.Contains(t, err.Error(), tt.errMsg)
})
}
}

func TestQueryRangeRoundtripEmpty(t *testing.T) {
req := &tempopb.QueryRangeRequest{
Step: uint64(time.Second), // you can't actually roundtrip an empty query b/c Build/Parse will force a default step
Expand Down
Loading