From 96f6afc3fb5d5fcf964f2e87464834d22449668e Mon Sep 17 00:00:00 2001 From: Ishwar Kanse Date: Thu, 22 Oct 2026 18:41:00 +0530 Subject: [PATCH] test: set Content-Type in empty-array round-trip trace RBAC tests TestSearchResponseEmptyTracesPreserved and TestTraceByIDResponseEmptyResourceSpansPreserved (added in #934) build their http.Response with an empty header and relied on unmarshal() falling back to JSON for a missing Content-Type. #937 made unmarshal()/marshal() return "unsupported content type" for anything other than protobuf or JSON. #934's CI ran against a base from before #937, so the tests passed on the PR but fail on main since the merge (d17ce87). Set Content-Type: application/json in both tests, matching what the makeResponse helper in this file already does. The assertions still go through the JSON unmarshaler, so the empty-array round-trip they exist to protect is still covered. Co-Authored-By: Claude Sonnet 5.5 --- api/traces/v1/trace_rbac_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/traces/v1/trace_rbac_test.go b/api/traces/v1/trace_rbac_test.go index 72952fcb7..4c4c6bdf6 100644 --- a/api/traces/v1/trace_rbac_test.go +++ b/api/traces/v1/trace_rbac_test.go @@ -550,7 +550,7 @@ func TestRBACSearchResult(t *testing.T) { // a zero-result Tempo search response must round-trip through the JSON // unmarshal/marshal cycle with "traces": [] intact, not silently dropped. func TestSearchResponseEmptyTracesPreserved(t *testing.T) { - resp := &http.Response{Header: http.Header{}} + resp := &http.Response{Header: http.Header{HeaderContentType: []string{ContentTypeJSON}}} searchResponse := &tempopb.SearchResponse{} in := []byte(`{"traces":[]}`) @@ -569,7 +569,7 @@ func TestSearchResponseEmptyTracesPreserved(t *testing.T) { // bug (see the comment on unmarshal/marshal). Before this fix, unmarshal/ // marshal used github.com/golang/protobuf/jsonpb for this type too. func TestTraceByIDResponseEmptyResourceSpansPreserved(t *testing.T) { - resp := &http.Response{Header: http.Header{}} + resp := &http.Response{Header: http.Header{HeaderContentType: []string{ContentTypeJSON}}} traceByIDResponse := &tempopb.TraceByIDResponse{} in := []byte(`{"trace":{"resourceSpans":[]}}`)