Skip to content

Commit dbcb34c

Browse files
committed
Fix avoid undefined services field in getServices response
When the backend has no traces, the getServices endpoint returned a nil services field, which is serialized as null in JSON. This caused the UI to fail validation, since it expects an array. This change ensures the services field is always returned as an empty array. Fixes #7921. Signed-off-by: Sujal Shah <sujalshah28092004@gmail.com>
1 parent 435a23d commit dbcb34c

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

cmd/jaeger/internal/extension/jaegerquery/internal/apiv3/http_gateway.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,9 @@ func (h *HTTPGateway) getServices(w http.ResponseWriter, r *http.Request) {
272272
if h.tryHandleError(w, err, http.StatusInternalServerError) {
273273
return
274274
}
275+
if len(services) < 1 {
276+
services = []string{}
277+
}
275278
h.marshalResponse(&api_v3.GetServicesResponse{
276279
Services: services,
277280
}, w)

0 commit comments

Comments
 (0)