Skip to content
Closed
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
4 changes: 2 additions & 2 deletions api/traces/v1/trace_rbac.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (

"github.com/go-kit/log"
"github.com/go-kit/log/level"
"github.com/golang/protobuf/jsonpb" // nolint:staticcheck
"github.com/golang/protobuf/proto" //nolint:staticcheck
"github.com/gogo/protobuf/jsonpb"
"github.com/gogo/protobuf/proto"
"github.com/grafana/tempo/pkg/tempopb"
commonv1 "github.com/grafana/tempo/pkg/tempopb/common/v1"
tracev1 "github.com/grafana/tempo/pkg/tempopb/trace/v1"
Expand Down
21 changes: 20 additions & 1 deletion api/traces/v1/trace_rbac_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ func TestResponseRBACModifier(t *testing.T) {
]
},
"scopeSpans": [
{"scope": {}, "spans": [{}]}
{"scope": {"attributes": []}, "spans": [{"attributes": [], "events": []}]}
]
}
]
Expand Down Expand Up @@ -756,6 +756,25 @@ func TestResponseRBACModifier(t *testing.T) {
}`, string(body))
})

t.Run("search endpoint preserves empty traces array", func(t *testing.T) {
// A zero-result search response from Tempo includes an empty (but
// present) "traces" array. The RBAC modifier must not drop that field,
// so clients can reliably rely on it being present.
resp := makeResponse(ctx, http.StatusOK, "/api/search", `{
"traces": [],
"metrics": {"inspectedBytes": "1868359", "completedJobs": 3, "totalJobs": 3}
}`, nil)

require.NoError(t, modifier(resp))

body, _ := io.ReadAll(resp.Body)
assert.JSONEq(t, `{
"traces": [],
"metrics": {"inspectedBytes": "1868359", "completedJobs": 3, "totalJobs": 3}
}`, string(body))
assert.Contains(t, string(body), `"traces":[]`, "traces field must be present as an empty array")
})

t.Run("search tag values endpoint is not modified", func(t *testing.T) {
resp := makeResponse(ctx, http.StatusOK, "/api/v2/search/tag/resource.service.name/values", `{
"tagValues": [
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ require (
github.com/go-kit/log v0.2.1
github.com/go-openapi/runtime v0.32.6
github.com/go-openapi/strfmt v0.27.0
github.com/gogo/protobuf v1.3.2
github.com/golang-jwt/jwt/v4 v4.5.2
github.com/golang/protobuf v1.5.4
github.com/gorilla/websocket v1.5.4-0.20250319132907-e064f32e3674
Expand Down Expand Up @@ -94,7 +95,6 @@ require (
github.com/go-viper/mapstructure/v2 v2.5.0 // indirect
github.com/gobwas/glob v0.2.3 // indirect
github.com/goccy/go-json v0.10.6 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v5 v5.3.1 // indirect
github.com/google/gnostic-models v0.7.0 // indirect
github.com/google/go-cmp v0.7.0 // indirect
Expand Down
Loading