diff --git a/modules/frontend/search_handlers.go b/modules/frontend/search_handlers.go index 0f819d514f3..190b47762b8 100644 --- a/modules/frontend/search_handlers.go +++ b/modules/frontend/search_handlers.go @@ -127,14 +127,17 @@ func newCombiner(req *tempopb.SearchRequest, cfg SearchSharderConfig) (combiner. return nil, err } - query, err := traceql.Parse(req.Query) - if err != nil { - return nil, fmt.Errorf("invalid TraceQL query: %s", err) - } + mostRecent := false + if len(req.Query) > 0 { + query, err := traceql.Parse(req.Query) + if err != nil { + return nil, fmt.Errorf("invalid TraceQL query: %s", err) + } - var mostRecent, ok bool - if mostRecent, ok = query.Hints.GetBool(traceql.HintMostRecent, false); !ok { - mostRecent = false + ok := false + if mostRecent, ok = query.Hints.GetBool(traceql.HintMostRecent, false); !ok { + mostRecent = false + } } return combiner.NewTypedSearch(int(limit), mostRecent), nil diff --git a/modules/ingester/instance_search.go b/modules/ingester/instance_search.go index 6d88bdf128e..2e7dfc1c488 100644 --- a/modules/ingester/instance_search.go +++ b/modules/ingester/instance_search.go @@ -40,14 +40,17 @@ func (i *instance) Search(ctx context.Context, req *tempopb.SearchRequest) (*tem span.AddEvent("SearchRequest", trace.WithAttributes(attribute.String("request", req.String()))) - rootExpr, err := traceql.Parse(req.Query) - if err != nil { - return nil, fmt.Errorf("error parsing query: %w", err) - } + mostRecent := false + if len(req.Query) > 0 { + rootExpr, err := traceql.Parse(req.Query) + if err != nil { + return nil, fmt.Errorf("error parsing query: %w", err) + } - var mostRecent, ok bool - if mostRecent, ok = rootExpr.Hints.GetBool(traceql.HintMostRecent, false); !ok { - mostRecent = false + ok := false + if mostRecent, ok = rootExpr.Hints.GetBool(traceql.HintMostRecent, false); !ok { + mostRecent = false + } } var (