You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by ha...@apache.org on 2025/04/27 01:04:59 UTC

(skywalking-banyandb) 01/02: Add error msg when no nodes matches requested stage

This is an automated email from the ASF dual-hosted git repository.

hanahmily pushed a commit to branch hwc
in repository https://gitbox.apache.org/repos/asf/skywalking-banyandb.git

commit 9bea4f21b00c8c30471fe0586c091e2a9de83446
Author: Gao Hongtao <ha...@gmail.com>
AuthorDate: Wed Apr 23 03:59:40 2025 +0000

    Add error msg when no nodes matches requested stage
    
    Signed-off-by: Gao Hongtao <ha...@gmail.com>
---
 banyand/liaison/grpc/measure.go | 3 +++
 banyand/liaison/grpc/stream.go  | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/banyand/liaison/grpc/measure.go b/banyand/liaison/grpc/measure.go
index 15c72fa5..f436ff67 100644
--- a/banyand/liaison/grpc/measure.go
+++ b/banyand/liaison/grpc/measure.go
@@ -223,6 +223,9 @@ func (ms *measureService) Query(ctx context.Context, req *measurev1.QueryRequest
 			nodeSelectors[g] = nil
 		}
 	}
+	if len(req.Stages) > 0 && len(nodeSelectors) == 0 {
+		return nil, status.Errorf(codes.InvalidArgument, "no node in the stage %s in group %s", req.Stages, req.Groups)
+	}
 
 	feat, err := ms.broadcaster.Publish(ctx, data.TopicMeasureQuery, bus.NewMessageWithNodeSelectors(bus.MessageID(now.UnixNano()), nodeSelectors, req.TimeRange, req))
 	if err != nil {
diff --git a/banyand/liaison/grpc/stream.go b/banyand/liaison/grpc/stream.go
index b1920878..5849373d 100644
--- a/banyand/liaison/grpc/stream.go
+++ b/banyand/liaison/grpc/stream.go
@@ -221,6 +221,9 @@ func (s *streamService) Query(ctx context.Context, req *streamv1.QueryRequest) (
 			nodeSelectors[g] = nil
 		}
 	}
+	if len(req.Stages) > 0 && len(nodeSelectors) == 0 {
+		return nil, status.Errorf(codes.InvalidArgument, "no node in the stage %s in group %s", req.Stages, req.Groups)
+	}
 	message := bus.NewMessageWithNodeSelectors(bus.MessageID(now.UnixNano()), nodeSelectors, req.TimeRange, req)
 	feat, errQuery := s.broadcaster.Publish(ctx, data.TopicStreamQuery, message)
 	if errQuery != nil {