diff --git a/CHANGELOG.md b/CHANGELOG.md index 76137ab4de2..717a926b2b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ We use *breaking :warning:* to mark changes that are not backward compatible (re ### Fixed +- [#7084](https://github.com/thanos-io/thanos/pull/7084) Store: fix parameter validation for proxy store + ### Added ### Changed diff --git a/pkg/store/acceptance_test.go b/pkg/store/acceptance_test.go index 34abc649ab1..069d7325550 100644 --- a/pkg/store/acceptance_test.go +++ b/pkg/store/acceptance_test.go @@ -33,6 +33,7 @@ import ( "github.com/thanos-io/thanos/pkg/store/labelpb" "github.com/thanos-io/thanos/pkg/store/storepb" "github.com/thanos-io/thanos/pkg/store/storepb/prompb" + storetestutil "github.com/thanos-io/thanos/pkg/store/storepb/testutil" "github.com/thanos-io/thanos/pkg/testutil/custom" "github.com/thanos-io/thanos/pkg/testutil/e2eutil" ) @@ -965,3 +966,30 @@ func TestTSDBStore_Acceptance(t *testing.T) { testStoreAPIsAcceptance(t, startStore) testStoreAPIsSeriesSplitSamplesIntoChunksWithMaxSizeOf120(t, startStore) } + +func TestProxyStore_Acceptance(t *testing.T) { + t.Cleanup(func() { custom.TolerantVerifyLeak(t) }) + + startStore := func(tt *testing.T, extLset labels.Labels, appendFn func(app storage.Appender)) storepb.StoreServer { + startNestedStore := func(tt *testing.T, extLset labels.Labels, appendFn func(app storage.Appender)) storepb.StoreServer { + db, err := e2eutil.NewTSDB() + testutil.Ok(tt, err) + tt.Cleanup(func() { testutil.Ok(tt, db.Close()) }) + appendFn(db.Appender(context.Background())) + + return NewTSDBStore(nil, db, component.Rule, extLset) + } + + p1 := startNestedStore(tt, extLset, appendFn) + p2 := startNestedStore(tt, extLset, appendFn) + + clients := []Client{ + storetestutil.TestClient{StoreClient: storepb.ServerAsClient(p1, 0)}, + storetestutil.TestClient{StoreClient: storepb.ServerAsClient(p2, 0)}, + } + + return NewProxyStore(nil, nil, func() []Client { return clients }, component.Query, nil, 0*time.Second, RetrievalStrategy(EagerRetrieval)) + } + + testStoreAPIsAcceptance(t, startStore) +} diff --git a/pkg/store/proxy.go b/pkg/store/proxy.go index ce4d391bf3b..96a67f9b752 100644 --- a/pkg/store/proxy.go +++ b/pkg/store/proxy.go @@ -540,6 +540,9 @@ func (s *ProxyStore) LabelValues(ctx context.Context, r *storepb.LabelValuesRequ g, gctx = errgroup.WithContext(ctx) storeDebugMsgs []string ) + if r.Label == "" { + return nil, status.Error(codes.InvalidArgument, "label name parameter cannot be empty") + } // We may arrive here either via the promql engine // or as a result of a grpc call in layered queries