Skip to content

Update from upstream repository - #16

Merged
openshift-merge-bot[bot] merged 5 commits into
ViaQ:mainfrom
observatorium:main
Oct 22, 2026
Merged

openshift-merge-bot[bot] merged 5 commits into
ViaQ:mainfrom
observatorium:main

Conversation

@xperimental

Copy link
Copy Markdown
Collaborator

IshwarKanse and others added 5 commits September 28, 2026 17:33
…e responses

/api/search and /api/v2/traces/{id} responses lose their "traces" or
"resourceSpans" key entirely when query RBAC is enabled
(WithTraceQLNamespaceSelectAndForbidOtherAPIs/responseRBACModifier), instead
of correctly returning an empty array. This crashes downstream consumers
that assume the field is always present when parsing a JSON response -- we
hit this via the OpenShift Distributed Tracing console plugin (using the
Grafana/Perses Tempo datasource), reported as TRACING-6841.

Root cause: responseRBACModifier's JSON path unmarshals and re-marshals the
response using github.com/golang/protobuf/jsonpb, a thin wrapper around
protojson. tempopb.SearchResponse and tempopb.TraceByIDResponse are both
gogo/protobuf-generated types (like tempopb.Trace, which already gets
special-cased via tempopb.MarshalToJSONV1/UnmarshalFromJSONV1 for exactly
this reason). The two jsonpb implementations disagree on whether a
populated-but-empty repeated field is distinct from an absent one:
golang/protobuf's jsonpb collapses an explicit empty array to a nil Go slice
on unmarshal, and omits a nil-or-zero-length slice on marshal regardless of
how it got that way, so the key never makes it back out. gogo/protobuf's
jsonpb preserves the distinction on both ends.

Fix: switch the shared unmarshal/marshal helpers to
github.com/gogo/protobuf/jsonpb for the JSON content-type path, since every
tempopb.* type they handle is gogo/protobuf-generated -- matching the
existing tempopb.Trace special-casing already in this file. This fixes both
/api/search and /api/v2/traces/{id} with one change. The protobuf
content-type path (added in #924 for the Grafana client) is unchanged and
unaffected: the wire format has no representation for "empty but present"
vs. "absent" to begin with, so proto.Marshal/proto.Unmarshal round-trip
correctly there regardless of library.

Testing:
- TestSearchResponseEmptyTracesPreserved and
  TestTraceByIDResponseEmptyResourceSpansPreserved: direct round-trip tests
  of unmarshal/marshal against explicit empty-array payloads for both
  response types.
- TestResponseRBACModifier/search_endpoint_with_zero_results_keeps_traces_as_an_empty_array:
  end-to-end test through the actual HTTP response modifier.
- TestTracesTempoSearchZeroResultsWithQueryRBAC (new, test/e2e): starts a
  real Tempo instance and a real observatorium-api binary with
  --traces.query-rbac=true, searches the empty instance, and asserts
  "traces":[] survives the round trip.
- TestTracesTempoSearchNonEmptyWithQueryRBAC (new, test/e2e): ingests a real
  trace with a k8s.namespace.name resource attribute, searches with query
  RBAC enabled, and confirms both correct round-tripping of real data and
  that RBAC redaction still strips unauthorized attributes correctly.
- Verified against tempo-operator's Gateway e2e/chainsaw tests: none assert
  on raw JSON shape for /api/search (all use `jq ".traces | length"`, which
  evaluates identically whether the key is missing or an empty array), so
  this is not a breaking change for existing consumers.
- Verified on a real OpenShift cluster running the OpenShift Distributed
  Tracing console plugin against a Gateway using this fix: the
  previously-crashing zero-result TraceQL search now works correctly, and
  RBAC-based attribute redaction is unaffected.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…aces-field

fix: preserve empty traces/resourceSpans arrays in RBAC-filtered trace responses
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 <noreply@anthropic.com>
…-type

test: set Content-Type in empty-array round-trip trace RBAC tests

@JoaoBraveCoding JoaoBraveCoding left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@openshift-ci

openshift-ci Bot commented Oct 22, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: JoaoBraveCoding, xperimental

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:
  • OWNERS [JoaoBraveCoding,xperimental]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-bot
openshift-merge-bot Bot merged commit 6e30e9c into ViaQ:main Oct 22, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants